-
fixed number of result records
How can one indicate the maximum number of result records that should be returned in an SQL string?
E.g. when a DB table containing 5000000 records is read out with an SQL query, the WHERE clause can filter the number of records, but can return up to 5M records. Is it possible to indicate in the SQL query the maximum number of records that should be returned to optimize performance?
-
Look at e.g. "AND ROWNUM <= 10" as part of the condition - beware if you have a sort you won't win on execution time.
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
-
Originally posted by DaPi
... beware if you have a sort you won't win on execution time.
In fact you'll probably win on execution time enormously, however the returned result will probably not be the one expected....
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
-
Is it really neccessary to say "if you want the right result" in every posting?
So, the answer to every tuning question is:
SELECT 1 FROM DUAL;
It's very fast, there's no disk activity and it's the shortest select statement I can think of.
On the other hand it might not be the result you want!
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|