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: TOP N Query

Re: TOP N Query

From: Harpreet Singh <harpreet_at_ruksun.com>
Date: Wed, 11 Dec 2002 19:22:59 +0530
Message-ID: <at7ekv$92h$1@news.vsnl.net.in>


Yes i agree that this would not be the efficient way when dealing with big tables. Hope i get more suggestions from people, who knows there might be a better way somewhere out there :))

--Harpreet
P.S. : I have another doubt that I am posting plz try to reply to that also whenever ur free. Subject heading is : Exec in Oracle

--
"Science is organized knowledge. Wisdom is organized life."
"Billy Verreynne" <vslabs_at_onwe.co.za> wrote in message
news:at7ddn$2kd$1_at_ctb-nnrp2.saix.net...

> Harpreet Singh wrote:
>
>
> > I tried the following query
> >> SELECT
> >> id
> >> FROM
> >> ( SELECT rownum SEQ, id FROM emp ORDER BY surname)
> >> WHERE seq BETWEEN 4 AND 11
> > And it worked, it gave the rows correctly from 4 to 11 even after the
> > order by clause. I think it must be first sorting the records in the db
> > temp space (somewhere) and then fetching it. And while fetching it
> > assigning row nums.
>
> Ah.. so it does. Hmm.. I was pretty certain that it did not work. Think I
> got confused with order by vs. top n queries with group by clauses.
>
> Anyway, it does make things simpler seeing that I'm wrong.
>
> The only problem with this approach is that you effectively perform a full
> table scan each time the query is run (even though only a subset of the
> result set is returned). Not a nice thing when dealing with a large table.
>
> --
> Billy
Received on Wed Dec 11 2002 - 07:52:59 CST

Original text of this message

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