Subject | Re: Optimize first clause in select query |
---|---|
Author | diwic2 |
Post date | 2006-12-15T11:17:22Z |
Your suggestion did the trick (and saved my day) - thank you very
much!
The plan now changed to:
PLAN (MY_MESSAGES ORDER RDB$PRIMARY3)
// David
--- In firebird-support@yahoogroups.com, "Ann W. Harrison"
<aharrison@...> wrote:
much!
The plan now changed to:
PLAN (MY_MESSAGES ORDER RDB$PRIMARY3)
// David
--- In firebird-support@yahoogroups.com, "Ann W. Harrison"
<aharrison@...> wrote:
>
> diwic2 wrote:
> >
> > select first 200 msg, pid from my_messages
> > where nodeid = 104000007 and pid >= 3000
> > order by pid
> >
>
> Just a hunch, but this might help...
>
> select first 200 msg, pid
> from my_messages
> where nodeid = 104000007 and pid >= 3000
> order by nodeid, pid
>
>
> The optimizer doesn't realize that it can use the
> primary key index navigationally to avoid the sort
> unless you include both parts of the key in the
> order by list.
>
> Regards,
>
>
> Ann
>