Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lucene: Why the search cost increase with the page increase?

I am using ElasticSearch cluster with 1G cache for each machine. I configured the searcher that 5000/perpage.

When I search page 3, it cost about 400ms. But when I search page 300, the cost increased to more than 5000ms! About 60% cache was free at this situation.

Why the cost increased more than 10 times?

like image 275
sezina Avatar asked Feb 13 '23 10:02

sezina


1 Answers

In order to page that far, Elasticsearch has to retrieve all previous pages, just to discard them at the end. A search with from: 1000, size: 100 is equivalent to a search with from: 0, size: 100100, only that you just get the last 100 results. That also means, that every document has to be scored, which is a potentially expensive operation.

There was a recent optimization, that should improve performance in such cases, when you use a scroll search, see this github issue.

like image 88
knutwalker Avatar answered May 15 '23 23:05

knutwalker