Commit ff3bc32
Remove sp_QuickieStore wait-stats per-interval TOP (5) pre-filter
The CROSS APPLY that joined to sys.query_store_wait_stats had:
SELECT TOP (5) qsws.*
FROM sys.query_store_wait_stats AS qsws
WHERE qsws.runtime_stats_interval_id = qsrs.runtime_stats_interval_id
AND qsws.plan_id = qsrs.plan_id
...
ORDER BY qsws.avg_query_wait_time_ms DESC
so for each (interval, plan) it kept only the 5 wait categories with
the highest per-interval avg wait time and discarded the rest. The
outer query then GROUP BYs (plan_id, wait_category_desc) and sums
across intervals. The net effect: a wait category ranked 6+ in one
interval but present in another silently loses the first interval's
contribution, making the same plan's totals inconsistent run-to-run
depending on which intervals it executed in.
Removed the TOP (and the now-unused ORDER BY) so every captured wait
category contributes to the outer aggregation. QS caps wait
categories to a small set per (interval, plan), so removing the TOP
does not blow up row counts.
Verified sp_QuickieStore installs clean and runs without error
against PerformanceMonitor on SQL Server 2022 with @wait_filter.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fc16d14 commit ff3bc32
1 file changed
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10863 | 10863 | | |
10864 | 10864 | | |
10865 | 10865 | | |
10866 | | - | |
| 10866 | + | |
| 10867 | + | |
| 10868 | + | |
| 10869 | + | |
| 10870 | + | |
| 10871 | + | |
| 10872 | + | |
| 10873 | + | |
| 10874 | + | |
| 10875 | + | |
| 10876 | + | |
| 10877 | + | |
10867 | 10878 | | |
10868 | 10879 | | |
10869 | 10880 | | |
10870 | 10881 | | |
10871 | 10882 | | |
10872 | 10883 | | |
10873 | | - | |
10874 | | - | |
10875 | 10884 | | |
10876 | 10885 | | |
10877 | 10886 | | |
| |||
0 commit comments