Subject | RE: [firebird-support] whats the opposite of first? |
---|---|
Author | Leyne, Sean |
Post date | 2006-10-18T17:32:20Z |
Helen,
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
> > > You want to return a descending set that has its rows in ascendingis
> > > order, don't you? :-) With derived table support in Fb 2.0, it
> > > doable (if horrible!)Recursion??? There is no recursion.
> >
> >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).
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