benwtrent opened a new pull request, #12072: URL: https://github.com/apache/lucene/pull/12072
When https://github.com/apache/lucene/pull/672 was introduced, it added many nice rewrite optimizations. However, in the case when there are many multiple nested `Boolean` queries under a top level `Boolean#filter` clause, its runtime grows exponentially. The key issue was how the `BooleanQuery#rewriteNoScoring` redirected yet again to the `ConstantScoreQuery#rewrite`. This causes `BooleanQuery#rewrite` to be called again recursively , even though it was previously called in `ConstantScoreQuery#rewrite`, and THEN `BooleanQuery#rewriteNoScoring` is called again, recursively. This causes exponential growth in rewrite time based on query depth. The change here hopes to short-circuit that and only grow (near) linearly by calling `BooleanQuery#rewriteNoScoring` directly, instead if attempting to redirect through `ConstantScoreQuery#rewrite`. The absolute worst case I was able to test is many nested `SHOULD` clauses with a depth of 22. This ran for over 7 seconds without my change. With my change it took less than 70ms. I had to cancel the test (without my change) when the depth was 30. It was simply taking too long. closes: https://github.com/apache/lucene/issues/12069 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
