@@ -2550,42 +2550,31 @@ BEGIN;
25502550
25512551 RAISERROR (N ' check_id 32: filtered indexes and indexed views' , 0 ,1 ) WITH NOWAIT ;
25522552
2553- SELECT database_name ,
2554- COUNT (* ) AS count_filtered_indexes
2555- INTO #filtered_index_count
2556- FROM #IndexSanity
2557- WHERE filter_definition <> ' '
2558- GROUP BY database_name
2559- OPTION ( RECOMPILE );
2560-
2561- SELECT i .database_name ,
2562- COUNT (* ) AS count_indexed_views
2563- INTO #indexed_view_count
2564- FROM #IndexSanity AS i
2565- JOIN #IndexSanitySize AS sz ON i .index_sanity_id = sz .index_sanity_id
2566- WHERE is_indexed_view = 1
2567- GROUP BY i .database_name
2568- OPTION ( RECOMPILE );
2569-
25702553 IF NOT (@Mode = 0 )
25712554 INSERT #BlitzIndexResults ( check_id, index_sanity_id, Priority, findings_group, finding, [database_name], URL , details, index_definition,
25722555 secret_columns, index_usage_summary, index_size_summary )
2573- SELECT 32 AS check_id,
2556+ SELECT DISTINCT
2557+ 32 AS check_id,
25742558 NULL AS index_sanity_id,
25752559 250 AS Priority,
25762560 N ' Feature-Phobic Indexes' AS findings_group,
25772561 N ' Borderline: No filtered indexes or indexed views exist' AS finding,
2578- fic .database_name AS [Database Name],
2562+ i .database_name AS [Database Name],
25792563 N ' http://BrentOzar.com/go/IndexFeatures' AS URL ,
25802564 N ' These are NOT always needed-- but do you know when you would use them?' AS details,
2581- fic .database_name + N ' (Entire database)' AS index_definition,
2565+ i .database_name + N ' (Entire database)' AS index_definition,
25822566 N ' ' AS secret_columns,
25832567 N ' N/A' AS index_usage_summary,
25842568 N ' N/A' AS index_size_summary
2585- FROM #filtered_index_count AS fic
2586- JOIN #indexed_view_count AS ivc
2587- ON ivc .database_name = fic .database_name
2588- WHERE count_filtered_indexes = 0 AND count_indexed_views = 0
2569+ FROM #IndexSanity i
2570+ WHERE i .database_name NOT IN (
2571+ SELECT database_name
2572+ FROM #IndexSanity
2573+ WHERE filter_definition <> ' ' )
2574+ AND i .database_name NOT IN (
2575+ SELECT database_name
2576+ FROM #IndexSanity
2577+ WHERE is_indexed_view = 1 )
25892578 OPTION ( RECOMPILE );
25902579 END ;
25912580
0 commit comments