Skip to content

ESQL: Added LIMIT BY benchmarks#1087

Draft
ivancea wants to merge 3 commits intoelastic:masterfrom
ivancea:esql-limit-by
Draft

ESQL: Added LIMIT BY benchmarks#1087
ivancea wants to merge 3 commits intoelastic:masterfrom
ivancea:esql-limit-by

Conversation

@ivancea
Copy link

@ivancea ivancea commented Mar 12, 2026

Draft

To be merged after LIMIT BY feature is released (In tech preview): elastic/elasticsearch#112918

Added benchmarks similar to the existing "Large Schemas" (LIMIT) and TopN (SORT + LIMIT) ones.

Local benchmark results

LIMIT BY

Metric Task Value Unit
Min Throughput from_idx_limit_1_by_key_1000 4.31 ops/s
Mean Throughput from_idx_limit_1_by_key_1000 9.63 ops/s
Median Throughput from_idx_limit_1_by_key_1000 10.34 ops/s
Max Throughput from_idx_limit_1_by_key_1000 13.36 ops/s
50th percentile latency from_idx_limit_1_by_key_1000 48.3455 ms
90th percentile latency from_idx_limit_1_by_key_1000 62.2281 ms
99th percentile latency from_idx_limit_1_by_key_1000 85.7927 ms
100th percentile latency from_idx_limit_1_by_key_1000 119.196 ms
50th percentile service time from_idx_limit_1_by_key_1000 48.3455 ms
90th percentile service time from_idx_limit_1_by_key_1000 62.2281 ms
99th percentile service time from_idx_limit_1_by_key_1000 85.7927 ms
100th percentile service time from_idx_limit_1_by_key_1000 119.196 ms
error rate from_idx_limit_1_by_key_1000 0 %
Min Throughput from_idx_limit_10_by_key_1000 13.3 ops/s
Mean Throughput from_idx_limit_10_by_key_1000 16.82 ops/s
Median Throughput from_idx_limit_10_by_key_1000 17.58 ops/s
Max Throughput from_idx_limit_10_by_key_1000 18.23 ops/s
50th percentile latency from_idx_limit_10_by_key_1000 48.3263 ms
90th percentile latency from_idx_limit_10_by_key_1000 55.2346 ms
99th percentile latency from_idx_limit_10_by_key_1000 76.0557 ms
100th percentile latency from_idx_limit_10_by_key_1000 158.521 ms
50th percentile service time from_idx_limit_10_by_key_1000 48.3263 ms
90th percentile service time from_idx_limit_10_by_key_1000 55.2346 ms
99th percentile service time from_idx_limit_10_by_key_1000 76.0557 ms
100th percentile service time from_idx_limit_10_by_key_1000 158.521 ms
error rate from_idx_limit_10_by_key_1000 0 %
Min Throughput from_idx_limit_1000_by_key_1000 9.05 ops/s
Mean Throughput from_idx_limit_1000_by_key_1000 9.2 ops/s
Median Throughput from_idx_limit_1000_by_key_1000 9.19 ops/s
Max Throughput from_idx_limit_1000_by_key_1000 9.37 ops/s
50th percentile latency from_idx_limit_1000_by_key_1000 99.4275 ms
90th percentile latency from_idx_limit_1000_by_key_1000 119.911 ms
99th percentile latency from_idx_limit_1000_by_key_1000 176.433 ms
100th percentile latency from_idx_limit_1000_by_key_1000 225.489 ms
50th percentile service time from_idx_limit_1000_by_key_1000 99.4275 ms
90th percentile service time from_idx_limit_1000_by_key_1000 119.911 ms
99th percentile service time from_idx_limit_1000_by_key_1000 176.433 ms
100th percentile service time from_idx_limit_1000_by_key_1000 225.489 ms
error rate from_idx_limit_1000_by_key_1000 0 %
Min Throughput from_idx_limit_10000_by_key_1000 10.22 ops/s
Mean Throughput from_idx_limit_10000_by_key_1000 10.42 ops/s
Median Throughput from_idx_limit_10000_by_key_1000 10.34 ops/s
Max Throughput from_idx_limit_10000_by_key_1000 10.74 ops/s
50th percentile latency from_idx_limit_10000_by_key_1000 89.1841 ms
90th percentile latency from_idx_limit_10000_by_key_1000 101.843 ms
99th percentile latency from_idx_limit_10000_by_key_1000 136.421 ms
100th percentile latency from_idx_limit_10000_by_key_1000 141.817 ms
50th percentile service time from_idx_limit_10000_by_key_1000 89.1841 ms
90th percentile service time from_idx_limit_10000_by_key_1000 101.843 ms
99th percentile service time from_idx_limit_10000_by_key_1000 136.421 ms
100th percentile service time from_idx_limit_10000_by_key_1000 141.817 ms
error rate from_idx_limit_10000_by_key_1000 0 %

SORT + LIMIT BY

Metric Task Value Unit
Min Throughput topnby_by_payment_type_query 0.1 ops/s
Mean Throughput topnby_by_payment_type_query 0.1 ops/s
Median Throughput topnby_by_payment_type_query 0.1 ops/s
Max Throughput topnby_by_payment_type_query 0.1 ops/s
50th percentile latency topnby_by_payment_type_query 9815.24 ms
90th percentile latency topnby_by_payment_type_query 9981.46 ms
100th percentile latency topnby_by_payment_type_query 10060.8 ms
50th percentile service time topnby_by_payment_type_query 9815.24 ms
90th percentile service time topnby_by_payment_type_query 9981.46 ms
100th percentile service time topnby_by_payment_type_query 10060.8 ms
error rate topnby_by_payment_type_query 0 %
Min Throughput topnby_by_payment_type_esql_segment_partitioning 0.21 ops/s
Mean Throughput topnby_by_payment_type_esql_segment_partitioning 0.22 ops/s
Median Throughput topnby_by_payment_type_esql_segment_partitioning 0.22 ops/s
Max Throughput topnby_by_payment_type_esql_segment_partitioning 0.22 ops/s
50th percentile latency topnby_by_payment_type_esql_segment_partitioning 4569.03 ms
90th percentile latency topnby_by_payment_type_esql_segment_partitioning 4674.38 ms
100th percentile latency topnby_by_payment_type_esql_segment_partitioning 4867.54 ms
50th percentile service time topnby_by_payment_type_esql_segment_partitioning 4569.03 ms
90th percentile service time topnby_by_payment_type_esql_segment_partitioning 4674.38 ms
100th percentile service time topnby_by_payment_type_esql_segment_partitioning 4867.54 ms
error rate topnby_by_payment_type_esql_segment_partitioning 0 %
Min Throughput topnby_by_payment_type_esql_doc_partitioning 0.21 ops/s
Mean Throughput topnby_by_payment_type_esql_doc_partitioning 0.21 ops/s
Median Throughput topnby_by_payment_type_esql_doc_partitioning 0.21 ops/s
Max Throughput topnby_by_payment_type_esql_doc_partitioning 0.21 ops/s
50th percentile latency topnby_by_payment_type_esql_doc_partitioning 4651.93 ms
90th percentile latency topnby_by_payment_type_esql_doc_partitioning 5207.24 ms
100th percentile latency topnby_by_payment_type_esql_doc_partitioning 5590.16 ms
50th percentile service time topnby_by_payment_type_esql_doc_partitioning 4651.93 ms
90th percentile service time topnby_by_payment_type_esql_doc_partitioning 5207.24 ms
100th percentile service time topnby_by_payment_type_esql_doc_partitioning 5590.16 ms
error rate topnby_by_payment_type_esql_doc_partitioning 0 %
Min Throughput topnby_by_payment_type_vendor_id_esql_segment_partitioning 0.14 ops/s
Mean Throughput topnby_by_payment_type_vendor_id_esql_segment_partitioning 0.15 ops/s
Median Throughput topnby_by_payment_type_vendor_id_esql_segment_partitioning 0.15 ops/s
Max Throughput topnby_by_payment_type_vendor_id_esql_segment_partitioning 0.15 ops/s
50th percentile latency topnby_by_payment_type_vendor_id_esql_segment_partitioning 6787.58 ms
90th percentile latency topnby_by_payment_type_vendor_id_esql_segment_partitioning 7080.68 ms
100th percentile latency topnby_by_payment_type_vendor_id_esql_segment_partitioning 7441.94 ms
50th percentile service time topnby_by_payment_type_vendor_id_esql_segment_partitioning 6787.58 ms
90th percentile service time topnby_by_payment_type_vendor_id_esql_segment_partitioning 7080.68 ms
100th percentile service time topnby_by_payment_type_vendor_id_esql_segment_partitioning 7441.94 ms
error rate topnby_by_payment_type_vendor_id_esql_segment_partitioning 0 %
Min Throughput topnby_by_payment_type_vendor_id_esql_doc_partitioning 0.15 ops/s
Mean Throughput topnby_by_payment_type_vendor_id_esql_doc_partitioning 0.15 ops/s
Median Throughput topnby_by_payment_type_vendor_id_esql_doc_partitioning 0.15 ops/s
Max Throughput topnby_by_payment_type_vendor_id_esql_doc_partitioning 0.15 ops/s
50th percentile latency topnby_by_payment_type_vendor_id_esql_doc_partitioning 6705.6 ms
90th percentile latency topnby_by_payment_type_vendor_id_esql_doc_partitioning 6901.74 ms
100th percentile latency topnby_by_payment_type_vendor_id_esql_doc_partitioning 7205.46 ms
50th percentile service time topnby_by_payment_type_vendor_id_esql_doc_partitioning 6705.6 ms
90th percentile service time topnby_by_payment_type_vendor_id_esql_doc_partitioning 6901.74 ms
100th percentile service time topnby_by_payment_type_vendor_id_esql_doc_partitioning 7205.46 ms
error rate topnby_by_payment_type_vendor_id_esql_doc_partitioning 0 %

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new benchmark operations/challenges to measure ES|QL’s upcoming LIMIT ... BY behavior, including comparisons against an equivalent-ish DSL approach in the nyc_taxis track and scalability coverage in the esql track.

Changes:

  • Add LIMIT ... BY ES|QL operations for nyc_taxis (segment vs doc partitioning) and corresponding challenge schedule entries.
  • Add LIMIT ... BY key_1000 ES|QL operations to the esql track and wire them into the esql_large_schema challenge.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
nyc_taxis/operations/default.json Adds DSL + ES
nyc_taxis/challenges/default.json Adds the new LIMIT BY operations to the nyc_taxis challenge schedule.
esql/operations/default.json Adds ES
esql/challenges/default.json Runs the new LIMIT ... BY operations in the esql_large_schema challenge.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +1504 to +1507
"size": 1000,
"sort": [{ "pickup_datetime": "desc" }],
"_source": false,
"fields": ["pickup_datetime", "dropoff_datetime", "trip_distance"]
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

Using collapse with inner_hits.size: 1000 returns the top collapsed hit plus up to 1000 inner hits per payment_type (i.e., up to 1001 docs/group), which isn’t directly comparable to LIMIT 1000 BY payment_type. Also, payment_type isn’t included in inner_hits.fields, so most returned hits won’t carry the grouping key. Consider adjusting inner_hits.size (e.g., 999) and/or aligning the returned fields so this query benchmark matches the ESQL benchmark’s cardinality/projection more closely.

Suggested change
"size": 1000,
"sort": [{ "pickup_datetime": "desc" }],
"_source": false,
"fields": ["pickup_datetime", "dropoff_datetime", "trip_distance"]
"size": 999,
"sort": [{ "pickup_datetime": "desc" }],
"_source": false,
"fields": ["pickup_datetime", "dropoff_datetime", "trip_distance", "payment_type"]

Copilot uses AI. Check for mistakes.
@ivancea ivancea requested a review from ncordon March 13, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants