Commit 427fa9f
Use MIN/MAX/AVG for sp_QuickieStore wait-time column aggregations
The plan-level wait-stats aggregation in the #query_store_wait_stats
insert used SUM() for every value including the ones typed and named
as min_query_wait_time_ms and max_query_wait_time_ms. Summing per-interval
minima and maxima inflates the output by the number of captured intervals
and produces numbers the column names promise they won't.
Changed the min_/max_ columns to MIN()/MAX(). Also changed
avg_query_wait_time_ms from SUM() to AVG(); summed averages are the
same kind of unit error. The outer GROUP BY is per (plan_id,
wait_category_desc), so MIN/MAX/AVG land on the right scope.
Left the HAVING SUM(min_query_wait_time_ms) > 0 as-is — as a gate for
"any wait time recorded in any interval" it's correct and changing it
would alter the row-filter semantics.
total_query_wait_time_ms still uses SUM — that one matches its name.
Verified the sproc installs and returns correctly-shaped wait output
against PerformanceMonitor on SQL Server 2022.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ca2dbd8 commit 427fa9f
1 file changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10832 | 10832 | | |
10833 | 10833 | | |
10834 | 10834 | | |
10835 | | - | |
| 10835 | + | |
10836 | 10836 | | |
10837 | 10837 | | |
10838 | 10838 | | |
10839 | | - | |
| 10839 | + | |
10840 | 10840 | | |
10841 | | - | |
| 10841 | + | |
10842 | 10842 | | |
10843 | 10843 | | |
10844 | 10844 | | |
| |||
0 commit comments