You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There was some additional logic involved in skipping triggers and stored
procedures. A comment Jeremiah left threw me off. It will not work
unless it's handled the same way as @OnlyQueryHashes; those things have
to be ignored, or there will be no query_hash column to check against.
Copy file name to clipboardExpand all lines: sp_BlitzCache.sql
+17-5Lines changed: 17 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -912,7 +912,8 @@ END
912
912
values will be inserted into #ignore_query_hashes. This is used to
913
913
exclude values from query results.
914
914
915
-
Stored procedures and triggers will still be queried.
915
+
Just a reminder: Using @OnlyQueryHashes will ignore stored
916
+
procedures and triggers.
916
917
*/
917
918
IF @IgnoreQueryHashes ISNOTNULL
918
919
ANDLEN(@IgnoreQueryHashes) >0
@@ -1004,6 +1005,7 @@ FROM (SELECT TOP (@Top) x.*, xpa.*,
1004
1005
1005
1006
SET @body +=N' WHERE 1 = 1 '+ @nl ;
1006
1007
1008
+
1007
1009
IF @IgnoreSystemDBs =1
1008
1010
SET @body +=N' AND COALESCE(DB_NAME(CAST(xpa.value AS INT)), '''') NOT IN (''master'', ''model'', ''msdb'', ''tempdb'', ''32767'') AND COALESCE(DB_NAME(CAST(xpa.value AS INT)), '''') NOT IN (SELECT name FROM sys.databases WHERE is_distributor = 1)'+ @nl ;
1009
1011
@@ -1024,6 +1026,15 @@ BEGIN
1024
1026
SET @body +=N' AND EXISTS(SELECT 1/0 FROM #only_query_hashes q WHERE q.query_hash = x.query_hash) '+ @nl ;
1025
1027
END
1026
1028
1029
+
/* filtering for query hashes */
1030
+
IF (SELECTCOUNT(*) FROM #ignore_query_hashes) >0
1031
+
AND (SELECTCOUNT(*) FROM #only_query_hashes) =0
1032
+
BEGIN
1033
+
SET @body +=N' AND NOT EXISTS(SELECT 1/0 FROM #ignore_query_hashes iq WHERE iq.query_hash = x.query_hash) '+ @nl ;
1034
+
END
1035
+
/* end filtering for query hashes */
1036
+
1037
+
1027
1038
IF @DurationFilter ISNOTNULL
1028
1039
SET @body +=N' AND (total_elapsed_time / 1000.0) / execution_count > @min_duration '+ @nl ;
1029
1040
@@ -1061,14 +1072,14 @@ SELECT @body += ' ORDER BY ' +
1061
1072
1062
1073
1063
1074
1064
-
SET @body += N') AS qs
1065
-
CROSS JOIN(SELECT SUM(execution_count) AS t_TotalExecs,
1075
+
SET @body += N') AS qs
1076
+
CROSS JOIN(SELECT SUM(execution_count) AS t_TotalExecs,
1066
1077
SUM(CAST(total_elapsed_time AS BIGINT) / 1000.0) AS t_TotalElapsed,
1067
1078
SUM(CAST(total_worker_time AS BIGINT) / 1000.0) AS t_TotalWorker,
1068
1079
SUM(CAST(total_logical_reads AS BIGINT)) AS t_TotalReads,
1069
1080
SUM(CAST(total_logical_writes AS BIGINT)) AS t_TotalWrites
1070
1081
FROM sys.#view#) AS t
1071
-
CROSS APPLY sys.dm_exec_plan_attributes(qs.plan_handle) AS pa
1082
+
CROSS APPLY sys.dm_exec_plan_attributes(qs.plan_handle) AS pa
1072
1083
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
1073
1084
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp '+ @nl ;
1074
1085
@@ -1243,7 +1254,7 @@ BEGIN
1243
1254
END
1244
1255
1245
1256
1246
-
IF (@QueryFilter ='all'AND (SELECTCOUNT(*) FROM #only_query_hashes) =0)
1257
+
IF (@QueryFilter ='all'AND (SELECTCOUNT(*) FROM #only_query_hashes) =0AND (SELECTCOUNT(*) FROM #ignore_query_hashes) =0)
0 commit comments