Welcome to MSDN Blogs Sign in | Join | Help
Did you know? – SQL 2008 Management Studio shows missing indexes for a query in human readable format?
While working with a customer, we identified that there is a easy way to find missing index of a given query using Management Studio (SQL 2008 onwards). So I thought of sharing along with a demo. Below is the demo script to create objects needed.
 
set nocount on
go
USE [tempdb]
GO
-- create a table with two columns
CREATE TABLE [dbo].[MyTest](
[i] [int] IDENTITY(1,1) NOT NULL,
[j] [char](8000) NULL
)
GO
-- inserting 10000 rows
INSERT INTO dbo.MyTest (j) VALUES ('A')
GO 10000 -- this is another cool feature to run a batch in loop
-- below is to get the plan without running the query
SET SHOWPLAN_XML ON
GO
SELECT * FROM MyTest WHERE I = 5
GO
SET SHOWPLAN_XML OFF

Once you run above code and look at results in grid mode, you will see a hyperlink as below.

SSMS1

Clicking on hyperlink would open another windows in SSMS as shown below.

SSMS2

Hope this helps to someone in the world.

As always, comments are welcome.

- Balmukund

Posted: Thursday, August 13, 2009 7:24 AM by blakhani

Comments

VishalSaxena said:

this is really good post, handy sql command to get the missing indexes

# August 13, 2009 2:09 PM

Anders Lybecker said:

I know and I love it!

In SQL Server 2005 it was not easy to get the same information, but doable. See my blog post about the subject http://www.lybecker.com/blog/2008/12/01/easy-win-index-candidates-on-sql-server-2005/

# August 14, 2009 2:08 AM

blakhani said:

Hi Andres,

Thanks for the comment. You are absolutley correct that this can be done in SQL 2005 also but as my blog says "human readable format" :)

Balmukund

# August 14, 2009 2:15 AM

Shelendra said:

This is great stuff. one can direct look on what index is required in run time

# November 18, 2009 6:03 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker