Repository navigation
Description
Workload
Two repeating SQL queries on 115cd3c2, both every 10 s with ε=0.01, δ=0.001:
- Q1
SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY value), percentile_cont(0.9) WITHIN GROUP (ORDER BY value) FROM metrics WHERE ts > now() - INTERVAL '5' MINUTE - Q2
SELECT city, percentile_cont(0.9) WITHIN GROUP (ORDER BY value) FROM metrics WHERE ts > now() - INTERVAL '20' MINUTE GROUP BY city
Save as wl.json:
{"query_workload": {"language": {"sql": "datafusion_sql"}, "query_batch": null, "repeating_queries": [
{"query": "SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY value), percentile_cont(0.9) WITHIN GROUP (ORDER BY value) FROM metrics WHERE ts > now() - INTERVAL '5' MINUTE",
"demand": {"fixed_interval": 10000}, "requirements": {"accuracy": {"max_error": 0.01, "failure_probability": 0.001}},
"predictability": {"predictable": {"known_at": null}}},
{"query": "SELECT city, percentile_cont(0.9) WITHIN GROUP (ORDER BY value) FROM metrics WHERE ts > now() - INTERVAL '20' MINUTE GROUP BY city",
"demand": {"fixed_interval": 10000}, "requirements": {"accuracy": {"max_error": 0.01, "failure_probability": 0.001}},
"predictability": {"predictable": {"known_at": null}}}]},
"data_workload": {"arrival": {"ingesting": {"rows_per_second": 666.67}}, "sources": {"metrics": {"series_count": 100}}}}cargo run -p asap-devtools --bin stage_pipeline -- --workload wl.json --exhaustive --max-displayed 2000 --out out.json \
--table '{"name": "metrics", "columns": [{"name": "ts", "type": "timestamp", "nullable": false}, {"name": "city", "type": "utf8"}, {"name": "value", "type": "float64"}], "time_index": 0}'1. Plans that mix exact and a sketch for Q1 fail to compile
Any plan that computes one of Q1's percentiles exactly and the other with a sketch is rejected with executor_cannot_compile: … aggregate output names differ from measures. There are 84 of them (labels Q1 Kll · … and Q1 DDSketch · …). Plans that compute both percentiles the same way are not affected.
In these plans, the exact Aggregate computing the p50 has one measure (quantile, q=0.5) and the output schema ["quantile_0_5"], but output_names: []. As a result, mixed exact/sketch plans for a multi-measure query are never priced.
2. Q1 and Q2 share nothing
No candidate shares anything between Q1 and Q2, not even shared Scan (Q1, Q2), even though both read metrics. Q2's p90 per city over 20 min (120 × 10 s panes) could serve Q1's p90 over 5 min by merging the newest 30 panes and rolling up across cities, yet no candidate does this.
Activity
fix(pass1): an exact measure split from a sketched one keeps its outp…
fix(pass1): an exact measure split from a sketched one keeps its outp…
fix(pass1): an exact measure split from a sketched one keeps its outp…
zzylol commentedon Oct 22, 2026
Both problems are fixed and merged.
Problem 1 (#881, 61b5809). When Pass 1 split a multi-measure aggregate, the exact
Aggregateit built for a measure that stays exact hadoutput_names: []. It now names its one measure as the target names it. Result on this workload:executor_cannot_compilerejections are gone:{"costlier": 328, "executor_cannot_compile": 84}becomes{"costlier": 412};Q1 Kll · Q2 Kll) costs 0.6401 cost/s, so it is priced but not selected.Problem 2 (#887, 67f5e22; #883 was closed after a force-push broke its sync). What caused it, checked against the three suspected causes:
cse.rs,InternTable::intern) shares a non-ASAP node only when its rows have a unique key, and a table's rows have none. Equal scans are now shared.SummaryMergewith bothnewest_panesandgroup_byis still rejected. But a rollup stacked over a newest-panes merge was already valid IR. What was missing:GlobalRelationRegroup). It now stands for the global SQL aggregate: the executor outputs one empty state when there is no input state, so the answer is a NULL row.sized_for_all). It is a KLL with k = 345, the size each query has alone. KLL and DDSketch error does not depend on q, so one state serves both p50 and p90.Results on this workload (
stage_pipeline --exhaustive):shared Scan (Q1, Q2)one Kll for Q1, Q2 in 120 × 10s panes (Q1 newest 30)Tests (
sql_two_percentiles):percentile_cont;Open question: should equal scans always be shared, rather than offered as a choice? Offering it as a choice doubles the candidates for each shared table.
feat(pass2): share SQL table scans; a coarser grouping reads a finer …
feat(pass2): share SQL table scans; a coarser grouping reads a finer …