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: Tricky SQL Problem: Top "n" of queried records

Re: Tricky SQL Problem: Top "n" of queried records

From: Albert Balbekov <abalbekov_at_grtcorp.com>
Date: 1998/03/20
Message-ID: <35127FB5.C35F3E26@grtcorp.com>#1/1

>
>
> I have a similar problem that none of the posting addresses: performance
>
> Suppose table "A" has a billion rows
> Than:
>
> select * from A;
>
> Will return a billion rows:
> row1's data
> row2's data
> ...
> ...
>
> And the server will run a LONG TIME before it returns.
> To make the point, my application want to display only the first 3 rows.
> When user say next, my application will display the next 3 rows, and so
> on and so on. The user might leave this query after watching the first 9
> rows.
>
> The whole idea is: it does not make sense for the server to retrieve a
> billion
> rows (which takes a long time) when user might watch only the first 9 rows.
>
> The ideal solution is that the server will stop after 3 rows, and return the
> retrieved 3
> rows to user. When the "next 3" request is sent to server, server continue
> to fetch
> the next 3 rows. And this process goes on and on until user doen't want
> any more rows or until 1 billion rows are retrieved.
>
> Can anyone shed some light on this?
>
> Thanks,
>
> Xiaofeng

 Yes, it seems does not have sense to process all 1 billion rows IF those rows are previously sorted. But what if you need rows to be sorted in other way then they are phisically stored? Server must process all billion before it returns first 3 records!

Thanks

--
Albert Balbekov
Received on Fri Mar 20 1998 - 00:00:00 CST

Original text of this message

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