Subject Re: [firebird-support] query speed - confusing
Author Arno Brinkman
Hi,

> I'm trying (and failing) to understand why these 2 queries have
> different plans and hence different execution times, the first takes
> around 250ms and the other takes 125ms. I know these sound very small
> but this database has only 1% of the data (although the selectivity
> will be similiar).

The last query can use an index, because the order by clause in that query.
Can't you try to find a way to use an index for filtering on:

> WHERE O.ACTIVESTATUS = 0 AND UPPER(O.OSIDENT) STARTING WITH '110';

Why UPPER() ? if you check for numbers '110' ?

Maybe an expression index something?

Regards,
Arno Brinkman
ABVisie