Is anyone aware of a T-SQL script that can detect redundant indexes across an entire database? An example of a redundant index in a table would be as follows:
Index 1: 'ColumnA', 'ColumnB', 'ColumnC'
Index 2: 'ColumnA', 'ColumnB'
Ignoring other considerations, such as the width of columns and covering indexes, Index 2 would be redundant.
Thanks.
There are situations where the redundancy doesn’t hold. For example, say
ColumnCwas a huuge field, but you’d sometimes have to retrieve it quickly. Yourindex 1would not require a key lookup for:On the other hand
index 2is much smaller, so it can be read in memory for queries that require an index scan:So they’re not really redundant.
If you’re not convinced by my above argument, you can find “redundant” indexes like:
Bring cake for your users in case performance decreases “unexpectedly” 🙂