risdenk commented on PR #2221:
URL: https://github.com/apache/solr/pull/2221#issuecomment-1913296690

   > Is there a unit test you can recommend that I might run in a debugger 
looking at key spots, that would show that a score is being computed wastefully?
   
   `TestMainQueryCaching#testConstantScoreFlScore` and put a breakpoint at 
`SolrIndexSearcher` line 1620
   
   If there is `rows=0` and one of three cases, the scores are computed and 
sorted even though its not needed:
   * `fl` includes `score`
   * `sort` includes `score`
   * `q` is a non constant query
   
   If you walk through the existing if checks in `SolrIndexSearcher` line 1620, 
the first case isn't chosen since scores are requested. The second case doesn't 
match since its not a `*:*` or `MatchAllDocsQuery` - even if its a constant 
score query `useFilterForSortedQuery` is false and we don't really want to 
enable (and its false by default) that case (puts the `q` in the filter cache - 
related to your other question I'll answer below). The final case is 
`useFilterCacheForDynamicScoreQuery` which if `useFilterForSortedQuery` is 
false (which it is by default) we skip optimizations.
   
   The changes to `TestMainQueryCaching` also show the other cases where the 
`rows=0` check improves things. Avoids a full sort.
   
   > This seems contradictory. If the filterCache can compute the result, then 
wouldn't disabling the filterCache for the query (as I see you do in the PR) 
not use the filter cache then? I'm referring to the query, not the filters 
(which are processed the same either way).
   
   So the check I added makes sure we don't add the `q` query to the 
`filterCache`. We want to use the filterCache to compute the result, but don't 
want to store the `q` in the `filterCache` after its computed. This is similar 
to `useFilterForSortedQuery` but this is specifically the case of a `rows=0` 
query.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to