Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: how to tune up this query?

Re: how to tune up this query?

From: Ethel Aardvark <bigjobbies_at_hotmail.com>
Date: 30 Jan 2003 05:05:02 -0800
Message-ID: <1a8fec49.0301300505.46e10f1b@posting.google.com>


Susan,
Without trying it, could this not be re-written as follows:

  SELECT id, name, priority FROM table_name   WHERE stage = 'start' and state = 1
  AND rownum <= 1000
  ORDER BY stage ASC

Remember that rownun is treated differently from other fields and will not be applied until AFTER the sort has taken place.

ETA susana73_at_hotmail.com (Susan Lam) wrote in message news:<7186ed56.0301292013.6212b21c_at_posting.google.com>...
> I have a 3 million records table. I want to retrieve the first 1000
> records of the lowest number of priority. The query below is
> extremely slow. I am suspecting it's because the subquery is
> producing 200k records and it needs to sort the 200k records.
>
> SELECT id, name, priority FROM
> (SELECT id, name, priority FROM table_name
> WHERE stage = 'start' and state = 1 ORDER BY stage ASC)
> WHERE rownum <= 1000;
>
> Is there any way to tune up this? Or should I write this query in
> another way?
>
> Thanks,
> Susan
Received on Thu Jan 30 2003 - 07:05:02 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US