I’ve been doing some analysis of our indexes with the thought of dropping unused indexes - and conserving space in our 1 TB database. I’m running the query below and have identified some indexes that have no, or very low usage, that are good candidates to be dropped. I have one index that has very low seeks, scans, user updates and user lookups. The odd thing to me is that it’s the table’s clustered index and the table has about a dozen other indexes. How can it be that the clustered index shows such little usage? I thought that based on the B-Tree structure, all the other indexes would be pointing to the clustered index? If so, it makes sense to me that the clustered index would actually show a lot of usage, instead of showing practically no usage like it does now. Is my understanding not correct? If my understanding is not correct, how can I get an accurate count of my index’s usage?
SELECT OBJECTNAME = OBJECT_NAME(I.OBJECT_ID),
INDEXNAME = I.NAME,
I.INDEX_ID,
S.*
FROM SYS.INDEXES I
INNER JOIN SYS.OBJECTS O
ON I.OBJECT_ID = O.OBJECT_ID
INNER JOIN SYS.DM_DB_INDEX_USAGE_STATS S
ON S.OBJECT_ID = I.OBJECT_ID
AND I.INDEX_ID = S.INDEX_ID
WHERE OBJECTPROPERTY(O.OBJECT_ID,'IsUserTable') = 1
AND I.NAME IS NOT NULL and
OBJECT_NAME(I.OBJECT_ID) not like 'sys%'
AND I.NAME not like 'PK%' -- Ignore Pk's
and I.NAME not like 'UC%' -- Ignore unique constraints.
and OBJECT_NAME(I.OBJECT_ID) = 'MyTable'
ORDER BY (s.user_seeks) asc
Thanks in advance.
André