Subject RE: [firebird-support] whats the opposite of first?
Author Leyne, Sean
Helen,

> > > You want to return a descending set that has its rows in ascending
> > > order, don't you? :-) With derived table support in Fb 2.0, it
is
> > > doable (if horrible!)
> >
> >Why do you say horrible?
> >
> >I have been using derived tables and they are dream!!!
>
> Erm, not that derived tables are horrible (they are not!) but
> recursive calls to SELECT FIRST to get the nth, followed by the
> n-1th, followed by the n-2nd...etc...that's what I call horrible
> (from a performance POV).

Recursion??? There is no recursion.

The engine does not treat the derived table like an IN (SELECT ...

Rather it resolves the inner result set and then passes it to the next
level for operation.


As for performance, the statement:

SELECT * FROM (SELECT FIRST 5 * FROM Table ORDER BY 1 DESC) ORDER BY 1

Executes without any perceptible time difference, as compared to:

SELECT FIRST 5 * FROM Table ORDER BY 1 DESC

(I ran a test using a table with 2,700,000 rows)


Sean