Details
Description
SolrQueryIndex and FilterQueryParser use the OakSolrConfiguration#getRows setting in order to set the number of documents that should be fetched in batches while iterating the Cursor resulting from a certain query.
While this is an optimization that avoids loading all the results in memory in cases where only e.g. the first 10 results of the Cursor are visited, it tends to perform really bad when resultsets' cardinality is 10 times or more bigger than the 'rows' setting, because for each JCR query, 10 or more Solr queries are performed (with the additional network, Solr calls, etc. latencies).
In order to avoid that we could make use of the 'rows' setting in order to perform the first request to Solr and then adapt the subsequent paged requests (controlled by start and rows Solr HTTP parameters) to be run against the rest of the resultset in no more than 2 Solr queries. This can be done by looking at the numFound value from Solr's response header (from the first query) and set the start/rows parameters accordingly.