Skip to content

Commit 65a2ce1

Browse files
committed
Fix bug in select with writes query
Because I don't want to be called a liar.
1 parent 3949dcc commit 65a2ce1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sp_BlitzCache.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3382,7 +3382,10 @@ RAISERROR('Checking for selects that cause non-spill and index spool writes', 0,
33823382
WITH XMLNAMESPACES (
33833383
'http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS p )
33843384
, selects
3385-
AS ( SELECT s.QueryHash
3385+
AS ( SELECT CONVERT(BINARY(8),
3386+
RIGHT('0000000000000000'
3387+
+ SUBSTRING(s.statement.value('(/p:StmtSimple/@QueryHash)[1]', 'VARCHAR(18)'),
3388+
3, 18), 16), 2) AS QueryHash
33863389
FROM #statements AS s
33873390
JOIN ##BlitzCacheProcs b
33883391
ON s.QueryHash = b.QueryHash
@@ -3398,7 +3401,8 @@ UPDATE b
33983401
SET b.select_with_writes = 1
33993402
FROM ##BlitzCacheProcs b
34003403
JOIN selects AS s
3401-
ON s.QueryHash = b.QueryHash;
3404+
ON s.QueryHash = b.QueryHash
3405+
AND b.AverageWrites > 1024.;
34023406

34033407
/* 2012+ only */
34043408
IF @v >= 11

0 commit comments

Comments
 (0)