11

How can I find the query causing the missing index DMVs suggesting to create a particular index?

Thank you.

asked Jan 7, 2015 at 8:44

2 Answers 2

12

Short answer: you can't with 100% accuracy.

Long answer: you can query the plan cache to identify plans with missing index warnings and compare the results with what you find in sys.dm_db_missing_index_* DMVs. Here's a script that you could use to query the plan cache. If the plan doesn't get cached or gets pushed out the cache for any reason, you won't find any matches, so we're back to the short answer.

To be 100% sure, you would have to trace the workload and capture the plans with missing indexes. It's not lightweight and it's not trivial. Here's a script to do that. With a small effort it could be ported to Extended Events.

answered Jan 7, 2015 at 9:12
3

Querying the plan cache to look for the indexes involved in the calculation of finding missing indexes DMV's can be looked from below pasted link:

https://www.sqlskills.com/blogs/jonathan/finding-what-queries-in-the-plan-cache-use-a-specific-index/

and refer to link as well for more explanation on the same

http://blogs.lessthandot.com/index.php/datamgmt/dbadmin/sql-server-dba-tip-missing-index-dmv/

answered Jan 7, 2015 at 20:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.