On Thu, Apr 10, 2014 at 4:52 PM, Mohit Anchlia <[email protected]>wrote:

> I am trying to understand the Pros and Cons of using scroll vs from/size
> for pagination? Scroll document advises against using it for real time
> users but it doesn't say why.
>

I believe scrolls pin some state in memory until they expire or you scroll
all the way through them.  They are great for maintenance scripts that need
to get all the results but you don't want too many in flight at once.  I
think.


>
> Also, what are the disadvantages of using from/size? I read that
> pagination is not efficient because it always pulls the top sorted result
> in memory.
>
>
This one is easy.  Elasticsearch/lucene has to keep a min heap of all the
documents you find and the score that is from + size big.  Technically it
is min(from + size, max(rescore_window_size)).  Anyway, that means some
part of the query has O(n) space and O(n * log(n)) time complexity where n
is from + size.  That part might be dwarfed by some other action but it is
there.  And technically in the worst case the time complexity is more like
O(hits * log(n)) but thats not likely.

Nik

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAPmjWd3jWS7mbzjxpu7ED_nRoTQQJmmxYWNGNgmMuJH17-WuAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to