Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 find out what query is using an index
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kimi86
Yak Posting Veteran

79 Posts

Posted - 02/07/2013 :  07:20:04  Show Profile  Reply with Quote
I am trying to find out what query is using a particular index in my database.
When I look at sys.dm_db_index_usage_stats the count for User_seeks keeps going up but I dunno any place where it must be being used. I basically want to delete it as a work around since i have some space issues in my database and adding space will take some time. I know that the index is being used somewhere looking at sys.dm_db_index_usage_stats but i am quite puzzled what program or query is using it.. Any idea what I can do

srimami
Posting Yak Master

160 Posts

Posted - 02/08/2013 :  17:21:14  Show Profile  Reply with Quote
Use the following query and see if User_seeks or user_Scans are being used. If user_seeks & user_scans are Zero, you can drop the indexes.

SELECT OBJECT_NAME(S.[OBJECT_ID]) AS [OBJECT NAME],
I.[NAME] AS [INDEX NAME],
USER_SEEKS,
USER_SCANS,
USER_LOOKUPS,
USER_UPDATES
FROM SYS.DM_DB_INDEX_USAGE_STATS AS S
INNER JOIN SYS.INDEXES AS I
ON I.[OBJECT_ID] = S.[OBJECT_ID]
AND I.INDEX_ID = S.INDEX_ID
WHERE OBJECTPROPERTY(S.[OBJECT_ID],'IsUserTable') = 1

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000