Today I am sharing SQL query often required during performance tuning/Optimization phase of the project.The query makes use of system DMV’s provided by SQL server.Open new query window in SQL Server and fire the below query against the respective database.For this example,I have restricted the output to only 10 rows using the TOP clause.You can modify it as per your requirement.
SELECT TOP 10
ROUND(s.avg_total_user_cost * s.avg_user_impact *
(s.user_seeks + s.user_scans),0) AS [Total Cost]
, d.statement AS TableName
FROM sys.dm_db_missing_index_groups g
INNER JOIN sys.dm_db_missing_index_group_stats s
ON s.group_handle = g.index_group_handle
INNER JOIN sys.dm_db_missing_index_details d
ON d.index_handle = g.index_handle
ORDER BY [Total Cost] DESC
I would like to have feedback from my blog readers.
Please post your feedback, question, or comments about this article.