two indexes with same columns = problem
Posted in 2012
Hi,
Ifx 11.50 FC9X6
AIX 6.1
We have a table where two columns are used for filter :
create table tst ( col1 int , col2 int);
select * from tst where co1 = 9 and col2 = 350
Today exists an index over this two cols:
create index i1 on tst ( col2,col1);
For a specific SQL this index is used but will be more efficient if the
cols appear in reversed order;
Suggested index:
create index i2 on tst ( col1, col2 );
Reason:
if I execute this counts:
select count(*), 'col1' from tst where col1 = 9
union all
select count(*), 'col2' from tst where col2 = 350
the output is something like
15 'col1'
1800 'col2'
If I just create the second index, the engine still usinging the i1 .
If I drop both, and create i2 first and i1 after...then the engine use
i2 ...
So... when have 2 indexes with the same columns, the engine use the
index what was created first.
I look at documentation and found nothing... anyone know if have some
explanation or is a defect?
Regards
Cesar