File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate pagination performance problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate pagination performance problem" Watch "Hibernate pagination performance problem" New topic
Author

Hibernate pagination performance problem

kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
Hi

I am doing pagination in hibernate. The query returns me a very large data result set after a search.



Here the page size is 20 records per page. I am using SQL server 2008.

My application is performing very slow when getting navigating the result pages. I am confused about where the problem is....
Do opening a session like this and not closing it at the end is effecting performance.....
The above code will be executed each time the user clicks on next page or previous page buttons.

Thanks in advance for help.

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Page is not a Hibernate class I know. What does it do? Which API is it from?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
Here is the main part of page class code .....in my application.

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Can you enable SQL logging in Hibernate to see what SQL it is using? Pagination support in SQL Server is not as straight forward as it is in other databases so it would be interesting to see how Hibernate has chosen to do it.

Also:

Do opening a session like this and not closing it at the end is effecting performance.....

Not really. Any objects cached in the session will remain (and eat up memory) but the results of queries don't end up in the session cache.
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
The problem with your scroller is, that you open the scroller without limiting the amount of query-data of the scroller.

You limit your results-List, but that s not the same.

Try this:

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
The only question is, for what do we need a Scroller, when you can do that:

results = query.setFirstResult(page * pageSize).setMaxResults(pageSize + 1).list();

I use DB2 and a scroller is supported by the database, but I found out, that it is not faster than when using.

Look at the two versions:






For what do I need a scroller, when it is not faster even although the database supports Scroller!
kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
My main entity Client has a set called addressRecord which are lazily fetched.....

Each client has many addresses, something like this.....



Is this hitting the performance......

Thanks for your suggestions......I tried using them but still i see it very slow.

Thanks in advance






 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate pagination performance problem
 
Similar Threads
Pagination
Pagination
Pagination Problem
Pagination
pagination