Skip to content

perf(promql): evaluate range functions and aggregations in ClickHouse - #2664

Open
Makisuo wants to merge 24 commits into
promql/2-warehousefrom
promql/3-pushdown
Open

Makisuo wants to merge 24 commits into
promql/2-warehousefrom
promql/3-pushdown

Merge branch 'promql/2-warehouse' into promql/3-pushdown

2564734
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Nov 16, 2026 in 3m 24s

Confidence 10/10 · No issues found

🟢 Confidence 10/10 · safe to merge. Window arithmetic is exact at both bucket edges and the corpus runs every query with pushdown on and off; only the open steps/values pairing note needs care.
2 notes · tests covered · risk medium · 1/1 new units observable

Runs a panel's range function and by (...) aggregation as one ClickHouse query and rebuilds the evaluator's grid from its per-step values, so a selector's buckets never cross into the isolate. The gates are conservative and the per-window math mirrors the evaluator; the two earlier notes stand.

  • planPushdowns and buildPushdownQuery push rate, the *_over_time family and by (...) aggregations into one query
  • fromPushed reconstructs labels and step timestamps from the pushed rows the way the selector path does
  • Each stored bucket fans out to the steps whose window holds it, then the window is recombined
  • Selector reads now go through compiledQueryBounded with a 24 MB ceiling

Still open from earlier reviews

Production impact

Telemetry this change adds and removes (1)
  • ➕ span name PromqlQueryService.readPushdown · packages/backend/src/services/promql/PromqlQueryService.ts:188
What was checked
  • Bucket/window containment is exact: bucket k spans (origin+(k-1)w, origin+kw], so j*s-m < k <= j*s (ch/queries/promql.ts:190)
  • extrapolated, instantPair and the cross-bucket sums match extrapolatedRate/instantValue/pairTotals (lib/promql/src/engine/window.ts:82)
  • Group labels are mirrored in SQL and TS, including job/instance/resource keys (promql/labels.ts:141 vs labelValue)
Observability coverage: 1 of 1 changes observable
Change Kind Observable Evidence
PromQL pushdown read (readPushdown → compiledQueryBounded) outbound query yes Same executor path as compiledQuery (packages/query-engine/src/execution/executor.ts:615); maple.promql.function/maple.promql.aggregation annotate the span at PromqlQueryService.ts:190

2564734 · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.