-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Search results fetching pbm.
PostPosted: Tue Apr 26, 2011 5:59 am 
Newbie

Joined: Wed Oct 27, 2010 6:01 am
Posts: 4
Hi,

In hibernate when we use :-

query.setFirstResult (pageParams.getPageNumber() * pageParams.getPageSize()); -> (0*100 = 0)
query.setMaxResults (pageParams.getPageSize()); -> (100)

This will bring the first 100 records.

For the first time, when we click Page 1, hibernate will retrieve the first 0-100 records from the DB. This is fine. When the user clicks the Page 2, hibernate will retrieve 200 records (1-200) among which it will filter and display the next 100 records in this case it is 101-200. Imagine for the page “10” click, will fetch all the 10,000 records from the DB and keep it in its internal memory among which it will filter and display the records from 990-10,000.

This looks like a very expensive operation. Because the query that is genetrated will have only the rowNum<=100 0r 200 0r 10,000. Ideally it should generate something like :-

Select * from ( select * from ….. where rowNum <= 400) where rowNum => 300

Will fetch only 100 records from the DB as same as the first 100 records fetch , rather than fetching the whole 400 records and then doing the filter for 100 records.

Which is not the case here in Hibernate when i verify it with the showsql as "true" in properties. Please , correct me if i have gone wrong.

Thanks.


Top
 Profile  
 
 Post subject: Re: Hibernate Search results fetching pbm.
PostPosted: Wed Apr 27, 2011 6:54 am 
Newbie

Joined: Wed Oct 27, 2010 6:01 am
Posts: 4
Guys any response for this? Pls. do respond.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.