SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

DBA 101: What you may be missing with “Missing indexes”

If you’ve read my blog, I’m sure by now you know that I have no love for GUI tools. I will say they are improving every day and maybe, just maybe, we will see the day when you can click happily away and do everything you want. Sadly, this is not the day.

A while back, SSMS added the “Missing Index” data to the graphical query plan. They even made it really easy to add.

Simply right click and choose [Missing Index Details…]. Magically a script comes up that has the index we are looking for. *Cheers*

But wait, is there something else? If there wasn’t I probably wouldn’t be blogging about it; and, No. It’s not the fact that some people often forget to name their index and end up with “[<Name of Missing Index, sysname,>]” instead of something useful.

What am I missing?

If you’re one that has just been right-click adding then you’re probably missing the additional indexes that may or may not exist. That’s right there could be more. From my experience with SSMS 2016, when you right click you only get a script created for the first index group. Let’s take a visual of this issue.

You can run the following query against AdventureWorks2012:

select a.modifieddate, p.stateprovincecode, soh.SalesOrderNumber
from person.address a
inner join person.stateprovince p on (a.StateProvinceID = p.StateProvinceID)
inner join sales.salesorderheader soh on (soh.BillToAddressID = a.AddressID)
where a.stateprovinceid in (79, 81)

You should end up with the following plan:


Note, the single Missing Index shown in green text between the statement and the graphical plan. Right click it. Choose [missing index details…] and you get the following:

Missing Index Details from SQLQuery2.sql – (local).AdventureWorks2012 (SQLDev\sqldba (54))
The Query Processor estimates that implementing the following index could improve the query cost by 18.6298%.

USE [AdventureWorks2012]
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [Person].[Address] ([StateProvinceID])
INCLUDE ([AddressID],[ModifiedDate])

18.6298% improvement. Nice! Now let’s look at the XML.


Where’d these other 2 indexes come from? Looking closely we see that index 1 and 2 are the exact same; however, index 3 is completely different! Not only that it has an estimated improvement of 75.4381%!!

This is why I’m no fan of tools. I don’t know how they’re made so they are more than likely missing “all” the detail.

I don’t like XML where else can I look?

Don’t like the XML, no problem. Pressing the F4 key in SSMS will pop open the Properties window. From here you can see all the details you like that are hidden away in the XML. Just be sure to highlight the result (SELECT operator).


I hope this post and all my others have brought you something new. If you haven’t already, be sure to check out my other posts at:

SQL Server Central & SQLTechBlog.com

Also be sure to follow me on LinkedIn and Twitter!

Confessions of a Microsoft Addict

Daniel Janik has been supporting SQL Server for 18 years as a DBA, developer, architect, and consultant. He spent six years at Microsoft Corporation supporting SQL Server as a Senior Premier Field Engineer (PFE) where he supported over 287 different clients with both reactive and proactive database needs. Daniel has spoken at several SQL Saturday events across the US and Caribbean and regularly speaks at PASS local chapters.


Leave a comment on the original post [sqltechblog.com, opens in a new window]

Loading comments...