Subject Re: [firebird-support] Re: slow: "select first(1) * from table where partnumber >= :search order by partnumber"
Author Ann W. Harrison
b404_r66 wrote:

> PLAN SORT ((LAGERKARTE INDEX (IX_LAGERKARTE_BESTELLNR,
> IX_LAGERKARTE_BESTELLNR)))
>
> Is using the same plan. So an ascending index might help on descending
> orders as well?

All the plans are using the index to select the qualifying rows then
sorting those rows to product the FIRST 1.

Only the simplest of queries actually walk the index. As a general
rule, selecting the FIRST repeatedly is an n-squared operation, so if
you want to

> .. emulate single record displays and the
> movement of a sequentiel pointer through a sorted column.

the best strategy is to create a sorted stream and move through it with
a sequential pointer.


Regards,


Ann