Microsoft SQL Server 2008
Performance Tuning
Best Practices

How to find missing indexes?

 

Execute the following script in Query Editor to a list of missing indexes with seek statistics. To design a new index with CREATE INDEX statement : equality columns should be put before the (different) inequality columns, and together they should make the key of the index. Included columns should be added using the INCLUDE clause. Columns with low seek counts should be ignored.

use AdventureWorks2008;

 

select object_name(mid.object_id) as TableName,

migs.user_seeks as Seeks,

mid.equality_columns as Equality,

mid.inequality_columns as Inequality,

mid.included_columns as Included,

mid.statement as [Statement]

from sys.dm_db_missing_index_details mid

join sys.dm_db_missing_index_groups mig

on mid.index_handle=mig.index_handle

join sys.dm_db_missing_index_group_stats migs

on migs.group_handle=mig.index_group_handle

where database_id=db_id()

order by TableName

 

 

 

The Best SQL Server 2008 Training in the World
 
 
SQLUSA.com Home Page