Deval Sheth
Deval Sheth

Reputation: 91

How to improve Hibernate performance in Java?

I have thousands of records which need to be retrieved on a single user click. Currently it is giving me the results very slowly, I have to wait for a long time. Is there a way to improve retrieving these results using hibernate?

I have a case where a method which has a select query will run every single minute. This is where Hibernate is giving me the slow result. I am using Hibernate with MySQL.

Upvotes: 6

Views: 5675

Answers (2)

alexey28
alexey28

Reputation: 5210

Common practice is enabling of 2nd level cache and query cache. Than your data will be readed from memmory not from db.

Good article about it here

Other things can be helpfull:

1 Indexing - in case there is where and ordering - you have to build indexes for fields you are searching/ordering - this can improve search speed up 10 times

2 Denormalisation - if you have a lot of joins some denormalisation (putting all in single table) can help. But this should be final solution when everything else fails.

Upvotes: 6

JHS
JHS

Reputation: 7871

I would suggest you go for Pagination if you have to display the records on a web page and retrieve part of the records at one time say 100.

Upvotes: 0

Related Questions