Subject Order by slows down query (FB 2.5 SC on Linux 64 bits)
Author Stefan Sinne
The following query needs about 10 seconds to execute on a table with around 7 Mio. lines:

select * from lin_albaran_venta where nro_factura = '0000001' order by nro_albaran, nro_linea;
Plan:
PLAN (LIN_ALBARAN_VENTA ORDER PK_LIN_ALBARAN_VENTAPK INDEX (FK_LIN_ALBARAN_VENTA_13))

When adding field nro_factura to the order by, the query speeds up to 0,2 secs:

select * from lin_albaran_venta where nro_factura = '0000001' order by nro_factura, nro_albaran, nro_linea;
Plan:
PLAN SORT ((LIN_ALBARAN_VENTA INDEX (FK_LIN_ALBARAN_VENTA_13)))

nro_factura is a FK, and (nro_albaran, nro_linea) the PK of table LIN_ALBARAN_VENTA.

We recently upgraded from FB 2.1 to 2.5, and on 2.1 we didn't run into this problem.

Is there any solution to this, perhaps in the configuration file, or do we have to revise
all the order by's in our application, or perhaps even go back to FB 2.1?