-->
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: Pagination and sorting
PostPosted: Mon Apr 13, 2009 7:34 am 
Beginner
Beginner

Joined: Tue Feb 03, 2009 12:29 pm
Posts: 49
hi,

This is regarding a statement in the 'Hibernate search in action' book -
Quote:
The process of limiting the number of matching results returned is called pagination. Not only does it limit the number of domain objects loaded by Hibernate Search, it also limits the number of Document objects loaded by Lucene."


According to my understanding, sorting is done on all the matching documents in Lucene before pagination is applied. Suppose have 1000 records in the db and 1000 corresponding documents in the Lucene index. Sorting by one of the fields is requested and also pagination to retrieve the first 10 records. Sorting will be done in Lucene for all the 1000 records before pagination is to fetch the 10 records. Then how can the above statement be correct? Or does it mean something else?

Thanks,
Seema


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 13, 2009 12:28 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Good question.
I'm not sure how Lucene is doing this internally, but it is capable of sorting them without going throught the most expensive step which is extracting the term values from the index to produce the result.
Said otherwise, it's capable of doing a "blind sort" sorting the result without yet knowing what's going to be returned... you can experiment using projection (to disable entity loading from database) combined with sorting and pagination: you'll see it's faster when you have to return only 10 elements compared to 10000, even when both results are sorted the same way.
Make sure to have different orders of magnitude in the sizes of the testcases, as more stuff is happening behind the curtains like batch extraction.

_________________
Sanne
http://in.relation.to/


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.