When does a database index hurt performance?
Indexes speed up reads by maintaining an ordered structure alongside the table, and that structure has to be kept correct on every write. Every insert, update and delete must update every affected index, so a table with eight indexes does substantially more work per write than one with two.
That cost is the main way indexes hurt. On a write-heavy table it can dominate, and adding an index to fix one slow report can measurably slow the ingestion path that matters more.
Several other effects are worth knowing.
- Storage. Indexes can collectively exceed the size of the table itself, which affects backup times, restore times and how much of the working set fits in memory.
- Redundancy. A composite index on two columns already serves queries filtering on the first alone, so a separate single-column index on that first column is pure overhead. This is a common form of accumulated waste.
- Planner confusion. More candidate indexes means more plans to consider, and with imperfect statistics the planner can choose a worse one. An index that is used but should not be is harder to diagnose than one that is ignored.
- Low selectivity. Indexing a column with very few distinct values, such as a boolean or a status with three states, rarely helps, because matching rows are a large fraction of the table and a sequential scan is cheaper.
The practical discipline is to add indexes in response to measured slow queries rather than in anticipation, and to review them periodically. Most databases expose usage statistics per index, and an index with zero scans since the last restart is costing writes for nothing.