未加星标

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

字体大小 | |
[数据库(综合) 所属分类 数据库(综合) | 发布者 店小二03 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

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:


DBA 101: What you may be missing with “Missing indexes”
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]
GO
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [Person].[Address] ([StateProvinceID])
INCLUDE ([AddressID],[ModifiedDate])
GO
*/

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


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

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).


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

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 !

本文数据库(综合)相关术语:系统安全软件

主题: SQLXMLSQL ServerTwitterLinkedIn
分页:12
转载请注明
本文标题:DBA 101: What you may be missing with “Missing indexes”
本站链接:http://www.codesec.net/view/532275.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(综合) | 评论(0) | 阅读(58)