Subject | Re: PLAN SORT |
---|---|
Author | Adam |
Post date | 2007-08-07T21:19:13Z |
--- In firebird-support@yahoogroups.com, Alexandre Benson Smith
<iblist@...> wrote:
PLAN (FOO ORDER PK_FOO)
to
PLAN SORT ((FOO NATURAL))
The first plan is probably slower to complete, but much much faster to
retrieve the first record.
The OP should provide an example of what they are trying to achieve,
because sorting is required to implement the features like distinct
and group by. The only way to avoid sorting the dataset is to avoid
using queries that rely on the data being sorted.
Adam
<iblist@...> wrote:
>wrote:
> Adam wrote:
> > --- In firebird-support@yahoogroups.com, "radevojvodic" <vrade@>
> >Also don't use joins.
> >> Hi All,
> >>
> >> How can PLAN SORT be avoided in query. All indexes are used, no
> >> natural orders , slow quary.
> >>
> >
> > Don't use order by, group by, distinct or union.
> >
> > Adam
> >No, it still does a sort. The only thing this will change
>
> Or add 0 to numeric fields or concatenate '' to char fields that are
> sorted, example:
PLAN (FOO ORDER PK_FOO)
to
PLAN SORT ((FOO NATURAL))
The first plan is probably slower to complete, but much much faster to
retrieve the first record.
The OP should provide an example of what they are trying to achieve,
because sorting is required to implement the features like distinct
and group by. The only way to avoid sorting the dataset is to avoid
using queries that rely on the data being sorted.
Adam