: while the results would be identical irrespective of the order in which you
: AND
: A, B and C, will the response times of the following queries differ in any
: way?
: 
: C && B && A
: A && B && C

The queries won't be *cached* the same at the solr level, because the 
BooleanQuery generated by the parsers won't be 100% identical, but the 
execution of those (uncached) queries should be virtualy indential.

: Does Lucene/Solr pick the best query execution plan in terms of both space
: and time for a given query?

It's not a "query execution plan" so much as it is a "skip ahead" pattern.  
the Sub-Scorers for each of the sub-queries are looped over and each one 
is asked to identify the "first" doc id (X) that it matches, after or 
equal to the "first" doc id (Y) returned by the last sub-query consulted 
-- starting with Y=0.  And each time a new "X" is found, the looping 
starts again on the remaining subscorers until a match is found (or we run 
out of documents)

So regardless of what the order of clauses are in the original 
BooleanQuery, the Scorers for each clause are constantly reordered based 
on what the "first" document they match after the currently considered 
document is.  

-Hoss

Reply via email to