• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate pagination performance problem

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Page is not a Hibernate class I know. What does it do? Which API is it from?
 
kalyen kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the main part of page class code .....in my application.

 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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






 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic