Skip to content

Conversation

@romseygeek
Copy link
Contributor

@romseygeek romseygeek commented Oct 8, 2025

Rather than doing a two-phase iterator dance with advanceExact, we can
use the fact that doc values iterators all extend DocIdSetIterator and reuse
DocIdSetIteratorScorerSupplier if we know there are no multi-valued fields
in a segment.

We can also automatically rewrite to a MatchAllDocsQuery if the input
FieldData is a constant value.

@romseygeek romseygeek requested review from dnhatn and martijnvg October 8, 2025 14:29
@romseygeek romseygeek self-assigned this Oct 8, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Oct 8, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine
Copy link
Collaborator

Hi @romseygeek, I've created a changelog YAML for you.

@romseygeek
Copy link
Contributor Author

Our SortedBinaryDocValues class doesn't extend DocIdSetIterator, but I don't think it would be much work to make it do so and we could then get a speedup for that case too.

Copy link
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks Alan!

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice simplification 👍

@romseygeek
Copy link
Contributor Author

Hmpf, it appears that Ordinals don't implement docId() either, so this will need to be restricted to just numerics.

@romseygeek
Copy link
Contributor Author

I've updated this to pull doc values directly for the fields, rather than trying to re-use FieldData.

@romseygeek romseygeek merged commit 5a1f693 into elastic:main Oct 16, 2025
34 checks passed
@romseygeek romseygeek deleted the esql/single-value-optimization branch October 16, 2025 10:09
Kubik42 pushed a commit to Kubik42/elasticsearch that referenced this pull request Oct 16, 2025
Rather than doing a two-phase iterator dance with advanceExact, we can
use the fact that doc values iterators all extend DocIdSetIterator and reuse
DocIdSetIteratorScorerSupplier if we know there are no multi-valued fields
in a segment.

We can also automatically rewrite to a MatchAllDocsQuery if the input
FieldData is a constant value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/Compute Engine Analytics in ES|QL >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants