File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10863,15 +10863,24 @@ FROM
1086310863 FROM #query_store_runtime_stats AS qsrs
1086410864 CROSS APPLY
1086510865 (
10866- SELECT TOP (5)
10866+ /*
10867+ Pull every wait category captured for this (interval, plan).
10868+ The previous TOP (5) ORDER BY avg_query_wait_time_ms DESC here
10869+ dropped wait categories ranked 6+ per interval before the outer
10870+ GROUP BY ran, so a category that was (say) 6th worst in one
10871+ interval but 2nd worst in another would silently have the first
10872+ interval' ' s contribution missing from its totals. The outer
10873+ aggregation groups by (plan_id, wait_category_desc) and the
10874+ number of wait categories per interval is capped by QS at a
10875+ small set, so removing the TOP does not explode row counts.
10876+ */
10877+ SELECT
1086710878 qsws.*
1086810879 FROM ' + @database_name_quoted + N' .sys.query_store_wait_stats AS qsws
1086910880 WHERE qsws.runtime_stats_interval_id = qsrs.runtime_stats_interval_id
1087010881 AND qsws.plan_id = qsrs.plan_id
1087110882 AND qsws.wait_category > 0
1087210883 AND qsws.min_query_wait_time_ms > 0
10873- ORDER BY
10874- qsws.avg_query_wait_time_ms DESC
1087510884 ) AS qsws
1087610885 WHERE qsrs.database_id = @database_id
1087710886) AS qsws_with_lasts
You can’t perform that action at this time.
0 commit comments