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%.
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [Person].[Address] ([StateProvinceID])
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
9 thoughts on “DBA 101: What you may be missing with “Missing indexes””
Nicely done, sir!
Very nice article on missing indexes. The properties window on objects in the Execution Plan window was a hidden gem.
If you save your Execution Plan and then open it with “SQL Sentry Plan Explorer” it will show you all the missing indexes in several different views. It’s a pretty useful GUI as they go.
Never been a fan of 3rd party tools… But still good to know. It’s a wildly popular tool.
Just wanted to add that sometimes it will suggest an index which already exists and is not being utilized (I assume because of whatever hiccup is making it suggest the thing again).
This is usually due to the “included” columns. Note that the post also shows duplicate index recommendations due to Equality vs Inequality for the key.
Nice job Daniel. I agree that over dependence on the GUI is an issue a lot of DBAs. I would like to point out that when one is simply implementing the recommended indexes then one has more problems than the fact that the GUI does not show you all of the recommendations.
Many times the recommendations are very redundant. Particularly when one is dealing with very large tables, it is often better to restructure code rather than add an additional index.
Thanks for this research / info. Well done.
That is an awesome guide ty!!