Subject Re: Problem with query with ORDER BY DESC
Author Alexander V.Nevsky
--- In ib-support@yahoogroups.com, "Sandro Silveira" <sandro@r...>
wrote:
> > Indices in Firebird are one-way only. That is, ASC or DESC. Try
> > creating DESCending indices as well and see if that matters.

> Already do this:
>
> CREATE UNIQUE DESCENDING INDEX "TT_CHA_DESC"
> ON "TTALAO"("TT_SIG", "TT_PED", "TT_LOT", "TT_PRG", "TT_TAL",
"TT_CCU"
> );
>
> In my execution plan i force this but is more slow than ascending
> order...

Sandro, are you sure? In your primary post you showed you forced
another, ascending, index:

PLAN (TTALAO INDEX (TT_CHA))

BTW, natural sort is often more quick than indexed. Indexed sort
more quickly returns first rows but natural one more quickly returns
whole cursor if we make fetchall. Performing indexed sort we force
Firebird make many reads index-data, index-data ... and time is wasted
to move disk heads and re-load cashe on large cursors.

Best regards, Alexander.