Skip to content

An exact result is not reused for the same query with a looser accuracy target #903

Open

Description

@milindsrivastava1997

Workload

The same PromQL query twice on 4535c957, every 10 s: quantile_over_time(0.9, data[5m]), with Q1 exact and Q2 at ε=0.01, δ=0.001. data is a gauge with 10,000 series sampled every 15 s.

Save as wl.json:

{"query_workload": {"language": "promql", "query_batch": null, "repeating_queries": [{"query": "quantile_over_time(0.9, data[5m])", "demand": {"fixed_interval": 10000}, "requirements": {}, "predictability": {"predictable": {"known_at": null}}}, {"query": "quantile_over_time(0.9, data[5m])", "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": {"data": {"series_count": 10000, "metric_type": "gauge", "sample_interval": 15000}}}}
cargo run -p asap-devtools --bin stage_pipeline -- --workload wl.json --exhaustive --out out.json

Observation

Plan Q1 Q2 Cost per second
P6-m1 (selected) exact Aggregate KLL 0.166
P3-m1 exact Aggregate a second, identical exact Aggregate 0.184

Both plans share Scan and TimeRange. In P3-m1, the two exact Aggregate nodes are identical but are not shared. An exact answer meets any ε, so Q2 could read Q1's result.

Expected: a candidate in which Q2 reads Q1's exact aggregate. Its cost would be 0.084 (scan) + 0.020 (time range) + 0.040 (aggregate) = 0.144, cheaper than the selected 0.166.

Activity

  1. zzylol commented on Oct 23, 2026

    @zzylol
    Contributor

    Deferred until the memo search (#879, #888) lands. This sharing/reuse rule will be added as a memo transformation rather than to the legacy search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingoptimizerWorkload optimization and plan selection

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions