Reputation: 2018
I have a simple question. Assume that the following sql returns over milion records:
Select * from Table
If I only need to work with 100 records, will limiting rows increase significantly the performance and why ?
Example oracle sql :
Select * from Table where rownum<=100
Upvotes: 0
Views: 105
Reputation: 16
No . The best way to find an answer is quickly generate an Explain plan . And see the relative cost of execution . It will give you the quick view . Returning row is display part but fetching of the row done on the condition . So preferably it will not be slower and it attest what i am saying generate the explain plan it will give the clear picture
Upvotes: 0
Reputation: 1270483
If you are reading all the rows, then limiting the number of rows will be more efficient.
If you are reading the rows through -- say -- a cursor, then you probably will not see any difference in performance.
If your "table" is really a "view", then the two queries might optimize differently.
Upvotes: 3