DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: fixed number of result records

  1. #1
    Join Date
    May 2003
    Posts
    1

    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?

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    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

  3. #3
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    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?

  4. #4
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    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
  •  


Click Here to Expand Forum to Full Width