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
SQL: Removed the always on total hit tracking #70319
Conversation
If the query uses `COUNT(*)` the total hits are automatically tracked: https://github.com/elastic/elasticsearch/blob/a92a647b9f17d1bddf5c707490a19482c273eda3/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java#L639 Otherwise the `track_total_hits` is only useful for scrolling. If the query is translated to (https://github.com/elastic/elasticsearch/blob/ee5cc5442a8e01d7d8fa426748d0b086959bf99d/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/execution/search/Querier.java#L130): - a scroll query (all the non-agg only queries), ES will automatically provide accurate total hits without us having to flip the `track_total_hits` - agg-only query: implicit group by (result is single record) or composite aggregation. `track_total_hits` does not affect these queries, it can only affect document search hits Closes elastic#52787
Pinging @elastic/es-ql (Team:QL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
(was scheduled for slashing since a while back).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
If the query uses `COUNT(*)` the total hits are automatically tracked: https://github.com/elastic/elasticsearch/blob/a92a647b9f17d1bddf5c707490a19482c273eda3/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java#L639 Otherwise, the `track_total_hits` is only useful for scrolling. If the query is translated to: - a scroll query (all the non-agg only queries), ES will automatically provide accurate total hits without us having to flip the `track_total_hits` - agg-only query, the `track_total_hits` does not affect these queries (implicit group by (result is single record) or composite aggregation), it can only affect document search hits See translation at: https://github.com/elastic/elasticsearch/blob/ee5cc5442a8e01d7d8fa426748d0b086959bf99d/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/execution/search/Querier.java#L130 Closes elastic#52787
If the query uses `COUNT(*)` the total hits are automatically tracked: https://github.com/elastic/elasticsearch/blob/a92a647b9f17d1bddf5c707490a19482c273eda3/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java#L639 Otherwise, the `track_total_hits` is only useful for scrolling. If the query is translated to: - a scroll query (all the non-agg only queries), ES will automatically provide accurate total hits without us having to flip the `track_total_hits` - agg-only query, the `track_total_hits` does not affect these queries (implicit group by (result is single record) or composite aggregation), it can only affect document search hits See translation at: https://github.com/elastic/elasticsearch/blob/ee5cc5442a8e01d7d8fa426748d0b086959bf99d/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/execution/search/Querier.java#L130 Closes elastic#52787
If the query uses `COUNT(*)` the total hits are automatically tracked: https://github.com/elastic/elasticsearch/blob/a92a647b9f17d1bddf5c707490a19482c273eda3/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java#L639 Otherwise, the `track_total_hits` is only useful for scrolling. If the query is translated to: - a scroll query (all the non-agg only queries), ES will automatically provide accurate total hits without us having to flip the `track_total_hits` - agg-only query, the `track_total_hits` does not affect these queries (implicit group by (result is single record) or composite aggregation), it can only affect document search hits See translation at: https://github.com/elastic/elasticsearch/blob/ee5cc5442a8e01d7d8fa426748d0b086959bf99d/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/execution/search/Querier.java#L130 Closes #52787
If the query uses `COUNT(*)` the total hits are automatically tracked: https://github.com/elastic/elasticsearch/blob/a92a647b9f17d1bddf5c707490a19482c273eda3/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java#L639 Otherwise, the `track_total_hits` is only useful for scrolling. If the query is translated to: - a scroll query (all the non-agg only queries), ES will automatically provide accurate total hits without us having to flip the `track_total_hits` - agg-only query, the `track_total_hits` does not affect these queries (implicit group by (result is single record) or composite aggregation), it can only affect document search hits See translation at: https://github.com/elastic/elasticsearch/blob/ee5cc5442a8e01d7d8fa426748d0b086959bf99d/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/execution/search/Querier.java#L130 Closes elastic#52787
If the query uses
COUNT(*)
the total hits are automatically tracked:elasticsearch/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java
Line 639 in a92a647
Otherwise the
track_total_hits
is only useful for scrolling.If the query is translated to:
without us having to flip the
track_total_hits
track_total_hits
does not affect these queries, it can only affect document search hitselasticsearch/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/execution/search/Querier.java
Line 130 in ee5cc54
Closes #52787