|
1 | | --- Compile Date: 03/23/2026 17:38:09 UTC |
| 1 | +-- Compile Date: 03/23/2026 19:02:42 UTC |
2 | 2 | SET ANSI_NULLS ON; |
3 | 3 | SET ANSI_PADDING ON; |
4 | 4 | SET ANSI_WARNINGS ON; |
@@ -36737,7 +36737,7 @@ BEGIN |
36737 | 36737 | SELECT 'object_name: the stored procedure, function, or trigger this query belongs to, or "Adhoc" for ad hoc SQL' UNION ALL |
36738 | 36738 | SELECT 'query_sql_text: representative query text (the most-executed variant for this query_hash)' UNION ALL |
36739 | 36739 | SELECT 'query_plan: the most recent execution plan (XML) for this query_hash' UNION ALL |
36740 | | - SELECT 'top_waits: top 3 Query Store wait categories with total wait time in ms (SQL 2017+ only, NULL on 2016)' UNION ALL |
| 36740 | + SELECT 'top_waits: top 3 Query Store wait categories with total wait time in ms (SQL 2017+ with wait stats enabled, omitted otherwise)' UNION ALL |
36741 | 36741 | SELECT 'query_hash: the query_hash that groups all parameterized variants of the same query' UNION ALL |
36742 | 36742 | SELECT 'query_count: how many distinct query_ids share this hash (parameterized variants)' UNION ALL |
36743 | 36743 | SELECT 'plan_count: how many distinct plans exist across all variants. >1 may indicate plan instability.' UNION ALL |
@@ -41494,11 +41494,31 @@ SELECT |
41494 | 41494 | END + N', |
41495 | 41495 | pw.primary_window, |
41496 | 41496 | qi.object_name, |
41497 | | - rt.query_sql_text, |
| 41497 | + query_sql_text = |
| 41498 | + ( |
| 41499 | + SELECT |
| 41500 | + [processing-instruction(query)] = |
| 41501 | + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( |
| 41502 | + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( |
| 41503 | + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( |
| 41504 | + rt.query_sql_text COLLATE Latin1_General_BIN2, |
| 41505 | + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), |
| 41506 | + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), |
| 41507 | + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''),NCHAR(0),N'''') |
| 41508 | + FOR XML |
| 41509 | + PATH(N''''), |
| 41510 | + TYPE |
| 41511 | + ), |
41498 | 41512 | query_plan = |
41499 | 41513 | TRY_CONVERT(xml, qp.query_plan), |
41500 | | - qw.top_waits, |
41501 | | - s.query_hash, |
| 41514 | + ' + |
| 41515 | + CASE |
| 41516 | + WHEN @new = 1 |
| 41517 | + AND @query_store_waits_enabled = 1 |
| 41518 | + THEN N'qw.top_waits, |
| 41519 | + ' |
| 41520 | + ELSE N'' |
| 41521 | + END + N's.query_hash, |
41502 | 41522 | s.query_count, |
41503 | 41523 | s.plan_count, |
41504 | 41524 | qi.query_id_list, |
@@ -41832,9 +41852,15 @@ LEFT JOIN #hi_query_identifiers AS qi |
41832 | 41852 | ON s.query_hash = qi.query_hash |
41833 | 41853 | LEFT JOIN #hi_primary_window AS pw |
41834 | 41854 | ON s.query_hash = pw.query_hash |
41835 | | -LEFT JOIN #hi_query_waits AS qw |
| 41855 | +' + |
| 41856 | + CASE |
| 41857 | + WHEN @new = 1 |
| 41858 | + AND @query_store_waits_enabled = 1 |
| 41859 | + THEN N'LEFT JOIN #hi_query_waits AS qw |
41836 | 41860 | ON s.query_hash = qw.query_hash |
41837 | | -OUTER APPLY |
| 41861 | +' |
| 41862 | + ELSE N'' |
| 41863 | + END + N'OUTER APPLY |
41838 | 41864 | ( |
41839 | 41865 | SELECT TOP (1) |
41840 | 41866 | qsp.query_plan |
|
0 commit comments