Skip to content

Narrow the Query Store slicer's clock-skew margin to an hour; the interval-table move is blocked (#3953) - #4311

Merged
erikdarlingdata merged 1 commit into
devfrom
fix/3953-query-store-reads-interval-table
Sep 25, 2026
Merged

erikdarlingdata merged 1 commit into
devfrom
fix/3953-query-store-reads-interval-table

Conversation

@erikdarlingdata

@erikdarlingdata erikdarlingdata commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Part of #3953.

Why

#3953 asks the Query Store reads to stop deduplicating the raw slice on every pass. This PR ships one small part of that. The main change needs a design decision first (see "Not in this PR"), so #3953 stays open.

What changes

  • ViewerDataService.QueryStoreSlicerSql: the lower chunk-exclusion bound collection_time >= $2 - interval '1 day' becomes collection_time >= $2 - interval '1 hour'.
  • The slicer filters its window on COALESCE(interval_start_time_utc, collection_time) >= $2. An interval is always collected after it starts, so a row in the window also has collection_time >= $2. The margin below $2 is there only for clock skew between the monitored server and the store, and an hour covers that. A 24-hour window that ends now reads 25 hours of collection_time instead of 48.
  • The upper bound, collection_time <= $3 + interval '30 days', does not change. It covers Query Store's longest interval (1 day) plus up to 29 days of collector outage.
  • ViewerQueriesTests.QueryStoreSlicerSql_KeepsSlackenedCollectionTimeBoundsForChunkExclusion pins the new bound, and the comment in the SQL explains it.

Not in this PR

The main change in #3953 moves three Query Store reads onto query_store_interval_latest, the table #4208 added for PLAN_REGRESSION. The table as built cannot serve them:

  1. It stores only rows with execution_type_desc = 'Regular', and its key does not include execution_type_desc. All three reads also need the Aborted and Exception rows.
  2. Each of the three reads needs columns that the table does not have.

The analysis and the options for a fix are on #3953 (issuecomment-5835309188). #4310 tracks the other Query Store reads that still deduplicate the raw slice.

Test plan

  • ViewerQueriesTests.QueryStoreSlicerSql_KeepsSlackenedCollectionTimeBoundsForChunkExclusion checks the new bound.
  • No live comparison of the old and new slicer SQL, no EXPLAIN run and no local full suite ran for this PR. CI runs the full suite.
  • GitHub Actions CI on ec9690f4: build, Darling PostgreSQL tests and Lite tests all pass.

CHANGELOG entry

SECTION: Fixed
ENTRY:

🤖 Generated with Claude Code

https://claude.ai/code/session_01FVjn4PBJN71NQXdFo6ZxNQ

…ur (#3953)

Ruling item 2 on #3953: the slicer's collection_time floor already carries
interval_start_time_utc <= collection_time as its real bound, so the extra
day below the window start was pure clock-skew slack, over-broad by 23
hours. Narrowed to an hour, which still covers realistic skew between the
monitored server's clock and the store's. The ceiling (30 days, covering
Query Store's max interval length plus collector-outage catch-up) is a
different bound and is untouched.

QueryStoreSlicerSql_KeepsSlackenedCollectionTimeBoundsForChunkExclusion
updated to pin the new hour literal instead of the old day literal.

Ruling item 1 (moving this read, get_query_store_top and the WPF viewer's
QueryStoreTopSql onto query_store_interval_latest) is parked: the table
#4208 shipped is Regular-execution-type only (both by its write filter and
by an identity that omits execution_type_desc) and is missing most of the
columns these two reads select. Full analysis posted on #3953
(issuecomment-5835309188). Follow-up for the rest of the still-deduplicating
Query Store reads filed as #4310.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TszxYhJJbTEh4LrZ56NYo3
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