|
Hello, Can anybody explain about the index usage. The scenario is lets say, I've 30 indexes on a table (CI and NCI), I want to find out the index which is used maximum and the index used minimum, so that I can drop the unused index on a table. I've tried DMV, but did not know what to look after. Thanks in advance
(comments are locked)
|
|
Firstly, go and get this book - http://www.red-gate.com/our-company/about/book-store/dynamic-management-views - its free in pdf.
It takes you through the whole 9 yards of the dmvs not just index related ones.
You will end up using [dm_db_index_usage_stats] [dm_db_index_operational_stats] [dm_db_index_physical_stats] in various combinations. The usage stats shows which indexes are used for what. If seeks and scans are low and updates are high then it *might* be an index to drop.
(comments are locked)
|
|
The key is, you don't want to just know which indexes are "used," but how they're used. Looking at sys.dm_db_index_usage_stats will tell you if your indexes are getting scans or seeks. In general (and there are exceptions to this) you want to see seeks. But, you really have to evaluate not simple how many times an index is touched, scan or seek, but which procedures are calling them? You may have a query that's called once a day, but by the CEO, you might want to leave that index. All looking at the DMO will tell you is, if the index is used. You still have to do all the research around how, by what, when. Then, before you drop the indexes, you need to test your code to validate it's not negatively affected when you drop them. It's a huge job.
(comments are locked)
|
|
You can start by checking out Brent Ozars Index Tuning for SQL Server video and scripts.
(comments are locked)
|
|
In addition to the other answers, I would like to recommend you should also to take a look at the singleton_lookup in the sys.dm_db_index_operational_stats. That will give you an hint if you should alter one or more indexes to avoid costly key lookups, by creating covering indexes or even change the clustered index. But as you already know, it's a heavy investigation project, so you should go for low hanging fruits to prevent the worst performing queries. You can try to find the worst performing queries by using sys.dm_exec_stats and get the cached execution plans from sys.dm_exec_query_plan where you actually can find the used indexes.
(comments are locked)
|


You did good coming to this site. The information below is stellar. Good luck in your quest for index tuning. Once you master it, the sky is the limit for your career as a DBA.