Subject Re: Slow descending order select on joint tables
Author Sean
--- In firebird-support@yahoogroups.com, "Leyne, Sean" <Sean@...> wrote:
>
> Sean, (What a great name!)
>
> > I need to furtherly join table_A to a small table with only 5 records.
> > Now the query is revised as:
> >
> > select first 250 * from table_A A
> > left join table_B B
> > on A.column = B.column
> > where A.time > sometimestamp
> > order by A.ID desc
> >
> > Now it takes more than 1 minute :-(
> >
> > Can anyone please point out what is missing here?
>
> The FIRST predicate is evaluated based on the *results*.
>
> So, you're query is performing a full join for both tables, then
> returning the first 250 rows.
>
>
> Sean
>

Yes, a full join of two tables is what I want to. When running the
query above, a plan was printed in IBExpert:

PLAN SORT (JOIN (TABLE_A NATURAL,TABLE_B INDEX (PK_TABLE_B)))

So the descending index is not used in the query...