Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is an index (in a DBMS) a bad index?

Tags:

sql

indexing

Can anyone tell me when an index is a bad index?

like image 494
Anoop Avatar asked May 14 '09 04:05

Anoop


2 Answers

If the indexed column is never searched on and the table is heavily updated you don't get the benefit of performance that indeces are for. In contrary you might suffer performance hit.

like image 63
Rashack Avatar answered Oct 20 '22 20:10

Rashack


One circumstance under which an index is pretty much unconditionally bad is if there is another index which uses the same columns (in the same order) as a prefix:

CREATE INDEX ix_good ON SomeTable(Col1, Col2, Col3);
CREATE INDEX ix_bad  ON SomeTable(Col1, Col2);

The bad index is a waste of disk space and slows down modify operations to no benefit.

like image 32
Jonathan Leffler Avatar answered Oct 20 '22 20:10

Jonathan Leffler