-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Performance of numeric exact-match queries can be improved #11097
Comments
Some initial benchmarks:
Running the Query is a simple term query on status:
|
This isn't going to be enough. That should behave the same as the index query alone. The key piece of the Imagine you have a simple "A AND B" Now, imagine instead that tl;dr: We need a lead iterator for |
Hi @msfroh , will documentation for this feature be required for 2.12? If so, can you please create the doc issue, let me know who will be creating the initial doc PR, and add this dev issue to the unified tracker project? Thanks! |
No documentation changes will be required. It's just an under-the-hood optimization. |
Describe the bug
I was recently looking at a query that included a clause like
In this case,
test
was along
field, indexed as a point. Profiling the query (with"profiler":true
) to see why it was slow, I found that the query was parsing toPointRangeQuery(test:[0 TO 0])
, without wrapping it in anIndexOrDocValuesQuery
. In this case, thePointRangeQuery
was taking up a lot of the query time.I rewrote the query as:
That one did do the
IndexOrDocValuesQuery
wrapping, and it was much faster (latency dropped from 1.2 seconds to 350ms).Expected behavior
I would expect the the query mapping by
NumberFieldMapper.NumberType
would do theIndexOrDocValuesQuery
wrapping automatically.The implementation of
termQuery
should probably delegate torangeQuery
in most cases, just applying the range over the target value. For the various integer types, we can keep the optimization that returns aMatchNoDocsQuery
if the value is not an integer. (As a bonus, while we're there, we could return aMatchNoDocsQuery
for values outside permitted range of a field, like a negative value forunsigned_long
or a number>= 128
forbyte
.)At the same time, the implementation of
termsQuery
for number fields should just be aBooleanQuery
overtermQuery
when the number of terms is small. (For keyword fields, "small" means 16 or fewer clauses.)The text was updated successfully, but these errors were encountered: