Repository navigation
Description
Claude posting for Erik Darling.
The Query Store grid on the Queries tab can show far fewer rows than exist, and a wider range can show fewer rows than a narrower one. Nothing on the page says rows are missing.
What it looks like
On a SQL Server 2025 test server, the grid on a Past day range shows one row. The page asks for 20 (wwwroot/js/pages/server-tabs.js:654), and the reply says truncated: false.
Rows that get_query_store_top returns for the same window as top grows:
| Server, window | top 20 | top 50 | top 100 | top 200 |
|---|---|---|---|---|
| SQL Server 2025 test server, 24 hours | 1 | 2 | 3 | 13 |
| SQL Server 2025 test server, 12 hours | 1 | 1 | 6 | 17 |
| SQL Server 2022 test server, 24 hours | 16 | 18 | 27 | 32 |
- At
top: 500over 24 hours, the SQL Server 2025 test server read 39 rows and 38 fit the response budget. 27 of those 38 are not the monitor's statements, against the one row on the page. - At
top: 20on the same server, 4 hours returns 11 rows, 8 hours returns 4, and 12 hours returns 1.
Cause
rankedcuts the window to its candidates withLIMIT $8(Darling/PerformanceMonitor.Darling.Service/Mcp/DarlingDataReader.cs:2736). The value isTopFill.FinalCandidates(top)(:3135,:3260), which is 220 fortop: 20(Darling/PerformanceMonitor.Darling.Storage/TopFill.cs:52,:96).- The monitor's own statements are removed after that cut, in the tail (
DarlingDataReader.cs:2817, from Leave the monitor's own statement and dropped databases out of Query Store regressions (#6654) #6665), because the marker is only in the text the tail resolves. - Darling stores those rows, because its separate text fetch leaves the collector's inline text empty, so the collector's drop does not fire (
PerformanceMonitor.Collectors/QueryStoreCollector.cs:1803). - The candidate limit was sized for the
WAITFORtrim (Top Queries ranked by duration can come back short when WAITFOR statements rank high #5313), which removes a few rows. The monitor's own statements are one candidate for each database, query and plan, and a wider range holds more of them.
The tail removes only WAITFOR text and the monitor's own statements. The removed rows were not read one by one, because they never leave the store.
The Viewer has the same shape (Darling/PerformanceMonitor.Darling.Viewer/ViewerDataService.QueryStore.cs:419, :509, :576). Lite keeps inline text and drops these rows when it collects, so this cut does not apply to it.
Who sees it
Any Darling server where the monitor's own statements rank above the real ones for the window: a lightly used server, or one with many databases. On a busy server the real statements rank first and the page fills.
Fix
- Leave out the monitor's own statements in
ranked, beforeLIMIT $8, withQueryStoreSelfStatement.NotSelfOfKey(Darling/PerformanceMonitor.Darling.Storage/QueryStoreSelfStatement.cs:83), onceQueryStoreSelfKeys.ReadyAsyncsays the backfill has run. The Regressions read already does this (Darling/PerformanceMonitor.Darling.Service/Mcp/DarlingQueryStoreRegressionReader.cs:290,Darling/PerformanceMonitor.Darling.Storage/QueryStoreRegressionBaseline.cs:1139). Keep the tail's test for a store where the backfill has not run. - Make the same change in the Viewer's read.
- Add a test with more of the monitor's rows than candidates, and check that the page still fills with real rows. A test pins the hash of this statement's text, so update that too.
#7730 covers the older unmarked statements on this grid. This fix does not remove those rows until #7730 adds their keys.
Activity
Leave out the monitor's own statements before the Query Store candida…
Gate the six marker-only own-statement reads on the key table, add a …
Fix the three red CI classes on the own-statement key gate (#7736)
Leave out the monitor's own statements before the Query Store candida…
erikdarlingdata commentedon Nov 6, 2026
Claude posting for Erik Darling. Fixed on dev by #7749.