Skip to content

Commit a89bbeb

Browse files
BrentOzarCopilot
andauthored
sp_BlitzCache - handling unreadable databases
In the per-database plan cache check. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a2fbb1b commit a89bbeb

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

sp_BlitzCache.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,15 @@ LEFT JOIN sys.dm_exec_procedure_stats AS ps
16811681
CROSS APPLY sys.dm_exec_plan_attributes(qs.plan_handle) AS pa
16821682
WHERE pa.attribute = N'dbid'
16831683
AND pa.value <> 32767 /*Omit Resource database-based queries, we're not going to "fix" them no matter what. Addresses #3314*/
1684+
AND (
1685+
ISNULL(@IgnoreReadableReplicaDBs, 0) = 0
1686+
OR NOT EXISTS
1687+
(
1688+
SELECT 1
1689+
FROM #ReadableDBs AS rdb
1690+
WHERE rdb.DatabaseID = CONVERT(INT, pa.value)
1691+
)
1692+
)
16841693
OPTION (RECOMPILE);
16851694

16861695
RAISERROR(N'Checking plan cache age', 0, 1) WITH NOWAIT;

0 commit comments

Comments
 (0)