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

Home -> Community -> Usenet -> c.d.o.misc -> Re: instead of SELECT TOP: cursors or nested queries?

Re: instead of SELECT TOP: cursors or nested queries?

From: Bricklen <Xbricklen_at_yahoo.comX>
Date: Wed, 07 Jan 2004 21:51:39 GMT
Message-ID: <Lb%Kb.18532$ts4.8678@pd7tw3no>


Diego wrote:

> I'm using Oracle 9i. I need an equivalent of Sql Server's SELECT TOP
> with ORDER BY.
> I have found two different approaches to do this.
> 1- Declaring a cursor and fetching the rows I need.
> 2- Using a nested query to order the table in the inner select and
> rownum in the outer.
>
> Both solutions work right, but I want to know which has a better
> performance when my tables become large, i.e. more than 10K records.
> I guess that if I create an index on the column I order by there
> should be no significant differences in performance between those
> solutions, but I'm not sure.
>
> Can anybody give some advice?

Why not put it to the test? ROT's are only good if they match the results of your tests, I'd say.

Check with Tom Kyte's runstats package as well, for more details http://asktom.oracle.com/~tkyte/runstats.html Received on Wed Jan 07 2004 - 15:51:39 CST

Original text of this message

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