views:

27

answers:

1

Given a table (id, col1, col2), does it make sense to create the following indexes:

Index1 (col1) not unique

Index2 (col1, col2) not unique

I am faced with a legacy database that is full of those.

Can I safely delete Index1? Anwser needed for SQL Server and Oracle.

+1  A: 

yes, you can delete index 1, if you have Index2 (col1, col2), there is no need for Index1 (col1), drop the Index1 (col1)

If the query were to only need the Index1 (col1), then the use of Index2 (col1, col2) will have a slight extra overhead because of the extra column, that is minimal to the maintenance and expense of a complete extra index.

That said, if this legacy database is running fine, why make any changes?

KM
One reason is to cut down on pointless writes and storage due to maintaining a useless index...
Chris J