I have question, maybe from someone it see as stupid. Is Hibernate fast? I use it in system which would have really large count of queries to database. And performance become alerted. And other question off the point of current context. What would better - many simple query (with single table) or a bit less query with several JOIN?
Tanks for advance Artem
Depending on the number of selected Order entities, Hibernate might need to execute a huge number of queries that significantly slow down your application. This issue is easy to find. Hibernate's session statistics and Retrace provide you with the number of queries that were executed within a given session.
This problem occurs when Hibernate performs 1 query to select n entities and then has to perform an additional query for each of them to initialize a lazily fetched association. Hibernate fetches lazy relationships transparently so that this kind of problem is hard to find in your code.
From our experience Hibernate can be very fast. However, there can be many pitfalls that are specific to ORM tools including: Incorrect lazy loading, where too much or too little data is selected. N+1 select problems, where iterating over collections is slow.
Both Hibernate & JDBC facilitate accessing relational tables with Java code. Hibernate is a more efficient & object-oriented approach for accessing a database. However, it is a bit slower performance-wise in comparison to JDBC.
From our experience Hibernate can be very fast. However, there can be many pitfalls that are specific to ORM tools including:
List
should be avoided and prefer Set
so ordering information does not need to be included in the tableThe Improving Performance page in the Hibernate docs is a good place to start to learn about these issues and other methods to improve performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With