Adding index to the column already having an index

30 Views Asked by At

there are indexes available for each columns. for ex: indx1 on col1 and indx2 on col2. is it possible to create again a composite index indx3 by combining col1 and col2? col1 and col2 are used in the where condition. will indx3 is in effect?

1

There are 1 best solutions below

0
On

Yes, the query optimizer will look for the best matching index. If you include col1 and col2 in a composite index and query (where) for those two fields it will use this index.

You should also consider throwing away the index on col1 because the composite index can be used for queries on col1 too. It depends on the sequence of the columns in the composite index: the first column can queried without the second one.