Skip to content

Top-N raw reads apply the hourly rollups' zero-interval filter, so both tiers agree by construction (#4394) - #4414

Merged
erikdarlingdata merged 5 commits into
devfrom
fix/4394-raw-top-n-interval-honest
Sep 26, 2026
Merged

erikdarlingdata merged 5 commits into
devfrom
fix/4394-raw-top-n-interval-honest

Conversation

@erikdarlingdata

@erikdarlingdata erikdarlingdata commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Refs #4394.

Why

The hourly successors exclude zero-interval rows (sample_interval_seconds = 0): their CREATE bakes in TimescaleSupport.IntervalHonestSourceFilter (sample_interval_seconds IS DISTINCT FROM 0). The raw top-N reads did not carry the same filter, so the two tiers answered the same window through different row sets.

In real data that difference is empty. The collector writes a zero-interval row with zero deltas: CollectorDeltaCalculator returns (delta 0, interval 0) for a first sighting, a counter reset, and a gap past the delta policy, and a first sighting that did real work (#2235) carries its real interval. A 24-hour count on two production SQL Server stores found delta_worker_time summing to exactly 0 over every zero-interval row. So this change moves no CPU figure. It applies the filter so that a raw-served and an hourly-served read agree by construction, instead of by the collector's invariant (see #4394's close-out).

What changes

Darling/PerformanceMonitor.Darling.Service/Mcp/DarlingDataReader.cs: TopQueriesSql,
TopQueriesByHostObjectSql and TopProceduresSql each gain
AND {TimescaleSupport.IntervalHonestSourceFilter} in their WHERE clause, through the one
shared constant (matching the file's existing pattern of interpolating Storage constants into
$""" raw strings) — never a copied literal. TopQueriesHourlySql is untouched; it already
inherits the filter from its successor's CREATE.

Test plan

Ranking on the test seed

The seed plants a zero-interval row with a nonzero delta, a shape the collector does not write, so that the filter is observable:

Window WindowStart..WindowStart+1d, 0xTOPQ1 carries an ordinary row (500,000 CPU-us / 10
executions), a second ordinary row (300,000 CPU-us / 6 executions), and one zero-interval row
(700,000 CPU-us / 1 execution):

Tier Before (dev) After (branch)
Raw, 0xTOPQ1 total 1,500,000 CPU-us / 17 executions 800,000 CPU-us / 16 executions
Hourly, 0xTOPQ1 total (unchanged either side) 800,000 CPU-us / 16 executions 800,000 CPU-us / 16 executions

Before: raw and hourly disagreed by the planted row's delta. After: raw's own read
now excludes that row the same way the hourly successor's CREATE always has, so the two tiers
agree on the same window.

CHANGELOG entry

SECTION: None
ENTRY: None: raw and hourly top-N reads now apply the same row filter; no figure changes in real data (#4394).

…g the hourly rollup (#4394)

query_stats' zero-interval first-collection row can carry a delta_worker_time
cumulative since plan creation rather than a true per-interval delta. The
hourly successor already excludes this row from its CREATE (#3653's
IntervalHonestSourceFilter); TopQueriesSql, TopQueriesByHostObjectSql and
TopProceduresSql did not, so the same window ranked differently raw vs
hourly. Adds the same filter to all three raw consts, through the one
shared constant.

Refs #4394.
@erikdarlingdata erikdarlingdata changed the title Top-N-by-CPU raw reads exclude a plan's first-collection row, matching the hourly rollup (#4394) Top-N raw reads apply the hourly rollups' zero-interval filter, so both tiers agree by construction (#4394) Sep 26, 2026
@erikdarlingdata
erikdarlingdata marked this pull request as ready for review September 26, 2026 14:15
@erikdarlingdata
erikdarlingdata merged commit 93f218a into dev Sep 26, 2026
15 of 16 checks passed
@erikdarlingdata
erikdarlingdata deleted the fix/4394-raw-top-n-interval-honest branch September 26, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant