Re: Limiting # rows returned by SQL query - during testing
Posted in 1995
In article <whudace.798475912@bgsuvax>,
whudace@bgsuvax.bgsu.edu (Bill Hudacek) wrote:
> In Oracle, I remember being able to limit the number of rows returned
> by a query (to speed up testing/debugging of SQL scripts, for
> example), but I don't remember how it was done. I haven't touched
> Oracle for quite awhile now... :)
[snip]
> (I didn't find this in the FAQ anywhere, using 'limit' as a search
> key. Is it there in some other 'context'?).
Thankyou thankyou thankyou for at least *looking* in the FAQ!
Here's the section you were looking for:
5.6 How can I SELECT a fraction (say 10%) of the database
----------------------------------------------------------
Todd A Wallace (twallace@mason1.gmu.edu) asked:
Ron Whiteleather (ronw@boi.hp.com) replied:
> I am trying to write an SQL statement that returns some fraction of all
> the rows it would normally return. For instance,
>
> SELECT firstname, lastname, city, state
> FROM bigdatabase
> WHERE state = "TX">
To return _approximately_ a fraction of the rows, try adding:
AND rowid=(trunc(rowid/x)*x)
where x is the 1/x fraction of rows you want returned. Again, this gives
only an approximate fraction of rows and is dependent on how uniformly the
data is physically distributed within the table. It does NOT guarantee
any randomness.
Regards,
Kerry S
--------------------------------------,-------------------------------------
Kerry Sainsbury, kerry@kcbbs.gen.nz | THE INFORMIX FAQ
Quanta Systems, Auckland, New Zealand | kcbbs.gen.nz:/informix/*
| mathcs.emory.edu:/pub/informix/faq/*
+64 9 377-4473 (work) 279-3571 (home) | http://www.garpac.com/informix.html