Subject Re: Problem with query with ORDER BY DESC
Author Sandro Silveira
Hi Alexander,

The problem is because i need the return in descending order, if i
use the "natural" order the application donĀ“t show the rows how i
need, in documentation of interbase is wrote to create indexes desc
when use "order by desc", i do this, but is very slow.

You are sure, the natural order is more quick, in this case that it
does not is the solution for me.

Still I do not have the solution for the problem...

Thanks,

Sandro.



--- In ib-support@yahoogroups.com, "Alexander V.Nevsky" <ded@h...>
wrote:
> --- 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.