Limey
Limey

Reputation: 2772

Estimated execution plan show needed indexes?

Ok,

I don't know if I am going crazy or not, but didn't the Estimated exexution plan use to show you what Indexes you would need to improve your performance? I used to this at my old job, but now it seems I have to using the tuning advisor. I don't mind the tuning advisor, but the way I did it before was so simple!

Thanks

Upvotes: 3

Views: 12581

Answers (1)

anon
anon

Reputation:

In both SSMS 2008 and in SSMS 2012 see this is working fine for both estimated and actual plans.

Here is a quick example to show that estimated and actual execution plans will both show missing indexes:

USE tempdb;
GO

CREATE TABLE dbo.smorg(blamp INT);
GO

INSERT dbo.smorg(blamp) SELECT n FROM
(
  SELECT ROW_NUMBER() OVER (ORDER BY c1.object_id)
  FROM sys.all_objects AS c1, sys.all_objects AS c2

) AS x(n);
GO

Now highlight this and choose estimated execution plan, or turn on actual execution plan and hit Execute:

SELECT blamp FROM dbo.smorg WHERE blamp BETWEEN 100 AND 105;

You should see a missing index recommendation. And you will see it represented here:

SELECT * 
    FROM sys.dm_db_missing_index_details 
    WHERE [object_id] = OBJECT_ID('dbo.smorg');

You can read more about the DMV here:

http://msdn.microsoft.com/en-us/library/ms345434.aspx

Also you should investigate SQL Sentry Plan Explorer (disclaimer: I work for SQL Sentry). This is a free tool that shows the missing indexes for estimated plans (if they are in the XML provided by SQL Server), doesn't have bugs like SSMS (where it repeats the same recommendation across multiple batches, even batches that don't mention the same tables), and generates actual execution plans without pulling all of the results across the network to the client - it just discards them (so the network and data overhead don't factor into to plan analysis).

Upvotes: 7

Related Questions