I have two existing indices in a DB as below
-
CREATE NONCLUSTERED INDEX IndexTable1
ON Table (fkAnothertable) -
CREATE NONCLUSTERED INDEX IndexTable2
ON Table (fkAnothertable)
INCLUDE (pkTable)
I had a hunch and my research seems to point that any queries that call #1 would be satisfied by #2 and that #1 is wasteful. I couldn’t find a definitive answer though.
Is this assumption correct and can I drop #1 and potentially improve performance?
Yes. #2 entirely covers #1 and possibly vice-versa in fact. Is
pkTableyour clustered index key? If so that will be included in #1 (at the key level because the non clustered index is not declared as unique).If
pkTableis not the clustering key then queries seeking on#1will still be satisfied by#2but#2may occupy more pages thus making scans that would have used#1a tad less efficient.