Repository navigation
Add Query Store total-CPU/total-duration compose measures, closes #2732 - #2738
Conversation
The compose catalog's query_store_stats roster could rank by executions, a per-interval peak, or a per-execution average - never by what a query group actually consumed. qs_total_cpu_us / qs_total_duration_us fill the hole as MeasureRatioMode.WeightedSum: the Weighted ratio's numerator with no denominator - SUM(avg * execution_count) on the raw route (riding the same #1841 dedup wrapper), and the corrected rollups' pre-multiplied cpu_us_weighted_sum / duration_us_weighted_sum columns directly on the CAGG routes. Riding the Ratio kind means the spec/wire seam needs no new special case: referenced as 'ratio', aggregation fixed, and time-series, ranked, and scalar modes all work unchanged. No migration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgLaaxFenZFZs1SntKQDEg
|
Reviewed. This is a clean, additive change to the Darling compose catalog (no Lite counterpart exists for this feature, so no Lite/Darling parity concern applies here — Lite has no Went through each No correctness, parity, or security issues found. Nothing to flag. |
… and #2710 entries) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgLaaxFenZFZs1SntKQDEg
|
Reviewed. This is a clean, well-scoped change — no T-SQL, no collector, no migration, no Lite files touched, so Lite/Darling parity is not a concern here (Lite has no compose/web-panel feature to keep in sync). Checked specifically:
No correctness, security, or parity issues found. |
…-keys Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgLaaxFenZFZs1SntKQDEg
Closes #2732.
What
The compose catalog's
query_store_statsroster could rank by executions, a per-interval peak, or a per-execution average — never by what a query group actually consumed, so "what burned the most CPU over this window" was not expressible against the box's headline dataset. This addsqs_total_cpu_usandqs_total_duration_us.How
A new measure shape,
MeasureRatioMode.WeightedSum— the Weighted ratio's numerator with no denominator, exactly the fix direction from the issue:ComposeCompiler.BuildValueExpr):SUM(f.avg_cpu_time_us * f.execution_count)— one new arm beside the Weighted arm, noNULLIF(there is no division). Rides the same Query Store aggregates double-count re-collected cumulative intervals - tier 2: interval identity + CAGG rebuild (tier 1 read-side dedup shipped in #1845) #1841 dedup wrapper as everything else on this source.ComposeCaggValueMapper):SUM(f.cpu_us_weighted_sum)/SUM(f.duration_us_weighted_sum)— the corrected hourly/daily rollups already materialize the product-sums, and the totals re-aggregate additively, soCanRemapQueryStoreadmits the mode andBuildQueryStoreExprreads the pre-multiplied column alone via the existingQsWeightedSumColumnmap.MeasureKind.Ratio(the aggregation is the definition, soValidAggsis empty like a ratio's) reusing the qs_avg measures'WeightedValueColumn/WeightColumnpair. That choice meansComposeSpecand the wire catalog need no new special case — referenced asratio, aggregate fixed,kind: "ratio"on the wire — and time-series, ranked (topquery_hashby total CPU), and scalar modes all work for free. Default unitsrather thanms: a window total across a store runs to seconds-to-hours.No migration, no collector change, no backfill.
Tests
Compile_WeightedSum_IsProductSum_WithNoDenominator(both keys) — raw product-sum, noNULLIF, µs→s conversion.Compile_OldWindow_QueryStore_WeightedSum_RoutesToCagg_ReadsTheWeightedSumColumnAlone— corrected-hourly remap, and never the raw column.WeightedSumQsTotals_ValidateAsRatios_AndRejectMeasureReference+WeightedSumQsTotals_SupportRankedMode_TopQueryHashByTotalCpu— the spec seam and the issue's headline panel.ComposedQueryStoreTotalCpuPanel_RunsOnPostgres_AndSumsTheProductOverDedupedIntervals(live, DARLING_TEST_PG-gated) — pins 500 × 41 = 20500 µs over the deduped fixture; an un-deduped product-sum would read 26500.ComposeCaggValueMapperTests:CanRemaprows for both keys plus exact-expression facts for the weighted-sum columns.EveryRatioMeasure_ReferencesRealSameSourceScalarsnow filters to Sum/Avg modes;WeightedRatio_Columns_AreRealPayloadColumnscovers both weighted modes (so the new measures' columns stay pinned to the collector's payload).Verified locally on macOS with a throwaway net10.0 harness against the real Service assembly (the Windows test suites can't run here): 30/30 checks pass — catalog shape, spec validation, raw/hourly/daily compiled SQL, mapper expressions byte-exact, ranked mode, and the wire catalog (
kind: "ratio",defaultAggregate: null, QS roster now 7 measures). CI is the arbiter for the xUnit suites.🤖 Generated with Claude Code
https://claude.ai/code/session_01JgLaaxFenZFZs1SntKQDEg