Skip to content

Top queries and procedures over long windows drop filters, report zeros for missing columns, and overstate coverage #4711

Closed

Description

@erikdarlingdata

When get_top_queries_by_cpu or get_top_procedures_by_cpu asks for a window longer than raw retention (about 72 hours and up), the read switches to the hourly rollup.

  • That path ignores parallel_only, min_dop and group_by=host_object, but the payload reports them as applied, and an empty page says the filter was applied in SQL.
  • Columns the rollup does not carry come back as 0 instead of null: reads, writes, physical reads, rows, spills, DOP and plan hash. The payload then shows is_parallel=false and avg_reads=0, although zero means "measured zero" everywhere else.
  • min_cpu_ms and max_cpu_ms on this path are the min and max of per-collection deltas, not the per-execution extremes the tool text promises.
  • Elapsed min/max and sql_handle exist in the rollup, but the query reader doesn't select them.
  • Query text is looked up one row at a time with no time bound, and a miss returns empty text with no note.
  • Coverage is reported as complete without checking where the rollup starts. A young store, or a young server on an older store, reports window_truncated=false for a window the data doesn't cover.
  • The hourly predicate drops the partial hour at the window start and includes the whole hour at an as_of end.

Evidence (1248a67)

Paths under Darling/PerformanceMonitor.Darling.Service/Mcp/ unless noted:

  • DarlingMcpDataTools.cs:566-569,575-578,584-586,601-612,645-661,694-701; procedures 754-756,769-773,795,810-814,822-823,837-841.
  • DarlingDataReader.cs:1220-1254,1262-1271,1312-1329,1413-1442,1519-1524,1649.
  • Darling/PerformanceMonitor.Darling.Storage/RetentionTierRouter.cs:68,210-260; rollup columns in TimescaleSupport.cs:2094-2098,9261,13510-13512.
  • The repo's rule: DarlingMcpHostService.cs:990-992 (a silently dropped knob is a confidently wrong answer). The live test doc Darling.Tests/TopQueriesHourlyRoutingLiveTests.cs:180-185 says the note should say the filter was NOT applied, but the test only checks that the note is non-empty.

Fix expected

  1. Filters: pass minMaxDop and rollUp into the router and force the raw tier when either is set (its floor probe already reports window_truncated). Refusing on the hourly tier doesn't work, because routing happens inside the reader. Make filter_applied, the group_by echo and the empty-page text tier-aware.
  2. Columns: null for reads, writes, physical reads, rows, spills, DOP and plan hash, and null min/max_cpu_ms on the hourly tier. Select elapsed min/max and sql_handle (the procedures reader already does). object_type at DarlingMcpDataTools.cs:795 is the in-file precedent.
  3. Text: one LEFT JOIN LATERAL in the ranked statement (like TopQueriesSql); null text plus a note when no raw row holds the hash. "Bounded by the raw floor" is a no-op.
  4. Coverage: a per-server first-bucket probe over the same stitched relation, judged with RawWindowFloor.IsTruncated (its 90-minute slack covers a first bucket up to an hour late). The store-wide floor alone misses the young-server case.
  5. Edges: snap effective_start to the first bucket and add a note on the trailing edge. The same predicate is used across the trend readers, so disclose rather than change one tool's predicate.

Tests that must fail before the fix

  • An hourly-tier call with min_dop: today it returns a rollup payload that claims the filter applied.
  • Missing columns are null, not 0, on the hourly tier.
  • A server whose first bucket is after the window start reports window_truncated=true.

Constraints

  • Run the MCP census and pin tests (McpPayloadContractCensusTests, the inventory pins).

Activity

  1. added
    bugSomething isn't working
    in-progressActively being worked by a local session or its agents (PR open or in flight)
    on Sep 29, 2026
  2. added a commit that references this issue on Sep 29, 2026
    dceb4f1
  3. erikdarlingdata commented on Sep 29, 2026

    @erikdarlingdata
    OwnerAuthor

    Claude posting for Erik Darling: fixed by #4715 (dceb4f1), merged to dev. get_top_queries_by_cpu and get_top_procedures_by_cpu on the hourly rollup now keep raw-only filters on raw, return null for the columns the rollup lacks, look text up inside the ranked read, check coverage per server against the rollup's first bucket and its materialization ceiling, and disclose the hour edges. On the hourly tier, cpu_attribution uses the span the rollup served.

  4. removed
    in-progressActively being worked by a local session or its agents (PR open or in flight)
    on Oct 12, 2026
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 working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions