first 'n' rows
Posted in 2000
Topics: Performance & Tuning
I would like to know how can I use the "FIRST_ROWS" optimizer directive and the "SELECT FIRST 'n' ROWS" directive. I don't know the syntax. Thank you for your help. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free!
In article <0cefcfc2.92a34d23@usw-ex0106-048.remarq.com>,
Esther <estherNOesSPAM@ts.es.invalid> wrote:
> I would like to know how can I use the "FIRST_ROWS" optimizer
directive
> and the "SELECT FIRST 'n' ROWS" directive. I don't know the syntax.
> Thank you for your help.
>
SET OPTIMIZATION FIRST_ROWS
SELECT FIRST <n> <column-list> from <table> ...
To reset the optimization, use SET OPTIMIZATION ALL_ROWS
Sent via Deja.com http://www.deja.com/
Before you buy.
sveiga@my-deja.com wrote:
>
> In article <0cefcfc2.92a34d23@usw-ex0106-048.remarq.com>,
> Esther <estherNOesSPAM@ts.es.invalid> wrote:
> > I would like to know how can I use the "FIRST_ROWS" optimizer
> directive
> > and the "SELECT FIRST 'n' ROWS" directive. I don't know the syntax.
> > Thank you for your help.
> >
>
> SET OPTIMIZATION FIRST_ROWS
>
> SELECT FIRST <n> <column-list> from <table> ...>
> To reset the optimization, use SET OPTIMIZATION ALL_ROWS
As Obnoxio points out these two directives, the SET OPTIMIZATION FIRST_ROWS
statement and the FIRST <n> inline directive are not directly related,
although it MAY be useful the set the former when using the latter this is
not required. The SET OPTIMIZATION ALL_ROWS/FIRST_ROWS tells the optimizer
whether its goal should be to minimize the time for fetching all of the
select set or to get the first few rows as quickly as posible even if it
means making the complete query run longer and cost more. The FIRST <n>
inline directive just tells the engine to stop fetching once the first 'n'
rows have been returned. I would suggest that one run the query under
SET EXPLAIN ON with and without FIRST_ROWS optimization goal set and seewhich is better in your environment.
Art S. Kagel