Skip to content

PopSQL: limited support.

Migrate now →

Missing indexes the optimiser asked for

The engine's own suggestions, ranked by the improvement it expects. Treat the top few as candidates, not orders.

SQL Server · SQL
SELECT TOP 20
       d.statement AS table_name,
       d.equality_columns,
       d.inequality_columns,
       d.included_columns,
       CAST(s.avg_total_user_cost * s.avg_user_impact * (s.user_seeks + s.user_scans) AS bigint) AS improvement_measure,
       s.user_seeks + s.user_scans AS uses
FROM sys.dm_db_missing_index_details d
JOIN sys.dm_db_missing_index_groups g ON g.index_handle = d.index_handle
JOIN sys.dm_db_missing_index_group_stats s ON s.group_handle = g.index_group_handle
WHERE d.database_id = DB_ID()
ORDER BY improvement_measure DESC

This query is part of the "SQL Server health" pack: connect the database in DataRunner and install the whole pack — queries, dashboard and checks — at once.