Subject Re: [firebird-support] Re: Compound Index
Author Ivan Prenosil
>> You shoud provide more informations - how big is the table,
>> how selective is Column1, how does the whole statement look,
>> plan and statistics, how much poor is "very poor", etc...
>>
>
> The table has 500,000 records and a total size of 2GB. Column1 and
> Column2 are integer fields and there is an index on Column1 alone and a
> compound index on (Column1, Column2).
>
> The sql is select first 100 * from my_table where column1 > 1 or
> column1 = 1 and column2 > 2.
>
> I've also try select first 100 * from my_table where column1 > 1 and
> select first 100 * from my_table where column1 = 1 and column2 > 2.
> Both are very slow. I expect the optimizer should be smart enough to
> pick the right index.

* You forgot to use
ORDER BY Column1, Column2
clause.

* How many records are there for Column1=1 ? Instead of
... where column1 > 1 ...
try this one
... where column1 >= 2 ...

Ivan
http://www.volny.cz/iprenosil/interbase/