Skip to content

Commit e5c9676

Browse files
committed
Closes #860
Moves some checks only available in newer versions to a new section where we valdate version first.
1 parent 0a9a561 commit e5c9676

File tree

1 file changed

+34
-26
lines changed

1 file changed

+34
-26
lines changed

sp_BlitzCache.sql

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,16 +2220,6 @@ FROM ##bou_BlitzCacheProcs b
22202220
WHERE b.QueryPlanCost IS NULL
22212221
OPTION (RECOMPILE);
22222222

2223-
RAISERROR(N'Checking for forced serialization', 0, 1) WITH NOWAIT;
2224-
WITH XMLNAMESPACES('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS p)
2225-
UPDATE ##bou_BlitzCacheProcs
2226-
SET is_forced_serial = 1
2227-
FROM #query_plan qp
2228-
WHERE qp.SqlHandle = ##bou_BlitzCacheProcs.SqlHandle
2229-
AND SPID = @@SPID
2230-
AND query_plan.exist('/p:QueryPlan/@NonParallelPlanReason') = 1
2231-
OPTION (RECOMPILE);
2232-
22332223
RAISERROR(N'Checking for plan warnings', 0, 1) WITH NOWAIT;
22342224
WITH XMLNAMESPACES('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS p)
22352225
UPDATE ##bou_BlitzCacheProcs
@@ -2428,22 +2418,6 @@ WHERE SPID = @@SPID
24282418
OPTION (RECOMPILE) ;
24292419

24302420

2431-
RAISERROR(N'Checking for ColumnStore queries operating in Row Mode instead of Batch Mode', 0, 1) WITH NOWAIT;
2432-
WITH XMLNAMESPACES('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS p)
2433-
UPDATE ##bou_BlitzCacheProcs
2434-
SET columnstore_row_mode = x.is_row_mode
2435-
FROM (
2436-
SELECT
2437-
qs.SqlHandle,
2438-
relop.exist('/p:RelOp[(@EstimatedExecutionMode[.="Row"])]') AS is_row_mode
2439-
FROM #relop qs
2440-
WHERE [relop].exist('/p:RelOp/p:IndexScan[(@Storage[.="ColumnStore"])]') = 1
2441-
) AS x
2442-
WHERE ##bou_BlitzCacheProcs.SqlHandle = x.SqlHandle
2443-
AND SPID = @@SPID
2444-
OPTION (RECOMPILE) ;
2445-
2446-
24472421
RAISERROR(N'Checking for computed columns that reference scalar UDFs', 0, 1) WITH NOWAIT;
24482422
WITH XMLNAMESPACES('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS p)
24492423
UPDATE ##bou_BlitzCacheProcs
@@ -2543,6 +2517,37 @@ WHERE ##bou_BlitzCacheProcs.SqlHandle = x.SqlHandle
25432517
AND SPID = @@SPID
25442518
OPTION (RECOMPILE);
25452519

2520+
IF @v >= 11
2521+
BEGIN
2522+
2523+
RAISERROR(N'Checking for forced serialization', 0, 1) WITH NOWAIT;
2524+
WITH XMLNAMESPACES('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS p)
2525+
UPDATE ##bou_BlitzCacheProcs
2526+
SET is_forced_serial = 1
2527+
FROM #query_plan qp
2528+
WHERE qp.SqlHandle = ##bou_BlitzCacheProcs.SqlHandle
2529+
AND SPID = @@SPID
2530+
AND query_plan.exist('/p:QueryPlan/@NonParallelPlanReason') = 1
2531+
OPTION (RECOMPILE);
2532+
2533+
2534+
RAISERROR(N'Checking for ColumnStore queries operating in Row Mode instead of Batch Mode', 0, 1) WITH NOWAIT;
2535+
WITH XMLNAMESPACES('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS p)
2536+
UPDATE ##bou_BlitzCacheProcs
2537+
SET columnstore_row_mode = x.is_row_mode
2538+
FROM (
2539+
SELECT
2540+
qs.SqlHandle,
2541+
relop.exist('/p:RelOp[(@EstimatedExecutionMode[.="Row"])]') AS is_row_mode
2542+
FROM #relop qs
2543+
WHERE [relop].exist('/p:RelOp/p:IndexScan[(@Storage[.="ColumnStore"])]') = 1
2544+
) AS x
2545+
WHERE ##bou_BlitzCacheProcs.SqlHandle = x.SqlHandle
2546+
AND SPID = @@SPID
2547+
OPTION (RECOMPILE) ;
2548+
2549+
END
2550+
25462551
IF @v >= 12
25472552
BEGIN
25482553
RAISERROR('Checking for downlevel cardinality estimators being used on SQL Server 2014.', 0, 1) WITH NOWAIT;
@@ -2621,6 +2626,8 @@ AND SPID = @@SPID
26212626
OPTION (RECOMPILE) ;
26222627

26232628
/* Trace Flag Checks 2014 SP2 and 2016 SP1 only)*/
2629+
IF @v >= 11
2630+
BEGIN
26242631
RAISERROR(N'Trace flag checks', 0, 1) WITH NOWAIT;
26252632
;WITH XMLNAMESPACES('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS p)
26262633
, tf_pretty AS (
@@ -2658,6 +2665,7 @@ FROM ##bou_BlitzCacheProcs p
26582665
JOIN #trace_flags tf ON tf.QueryHash = p.QueryHash
26592666
WHERE SPID = @@SPID
26602667
OPTION(RECOMPILE);
2668+
END
26612669

26622670
IF @SkipAnalysis = 1
26632671
BEGIN

0 commit comments

Comments
 (0)