Skip to content

Commit cfc1859

Browse files
CopilotBrentOzar
andauthored
sp_BlitzIndex: skip unindexed FK warning on unread tables
Agent-Logs-Url: https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/sessions/9da22ebd-5b7b-408c-9583-a02f90e23c36 Co-authored-by: BrentOzar <245462+BrentOzar@users.noreply.github.com>
1 parent 79daf06 commit cfc1859

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

sp_BlitzIndex.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6009,6 +6009,14 @@ BEGIN
60096009
(SELECT TOP 1 more_info FROM #IndexSanity i WHERE i.object_id=fk.parent_object_id AND i.database_id = fk.database_id AND i.schema_name = fk.schema_name)
60106010
AS more_info
60116011
FROM #UnindexedForeignKeys AS fk
6012+
WHERE EXISTS (
6013+
SELECT 1/0
6014+
FROM #IndexSanity i
6015+
WHERE i.object_id = fk.parent_object_id
6016+
AND i.database_id = fk.database_id
6017+
AND i.schema_name = fk.schema_name
6018+
AND (ISNULL(i.user_seeks, 0) + ISNULL(i.user_scans, 0) + ISNULL(i.user_lookups, 0)) > 0
6019+
)
60126020
OPTION ( RECOMPILE );
60136021

60146022

0 commit comments

Comments
 (0)