How to find what Stored Procedures are using what indexes?

后端 未结 5 1132
终归单人心
终归单人心 2021-02-15 18:34

I am trying to determine what indexes are no longer used in my Database. I have had great luck using the following query:

SELECT   OBJECT_NAME(S.[OBJECT_ID]) AS         


        
5条回答
  •  遇见更好的自我
    2021-02-15 18:54

    I don't have access to SQL Management Studio at home, but maybe you can look at the stored procdures dependancies (i.e. this store procedure depends on these tables and therefore may use these indexes)

    This page might give you some clue, like using the INFORMATION_SCHEMA.ROUTINES system table:

    SELECT routine_name, routine_type 
    FROM INFORMATION_SCHEMA.ROUTINES 
    WHERE ROUTINE_DEFINITION LIKE '%Employee%'
    

    You can populate this information into a temp table and then then use that to query for the indexes used, looking at the index usage stats.

    Sorry that I'm not able to give you a practical example, just a theorical example...

提交回复
热议问题