![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Because it does not have any rows. Your query probably has an order by and that is why it ran out of temp space.(You probably don't have a temp tablespace defined or even defined properly and your sort area size it probably pretty small - like 64 K) Rownum is the number of the row that is returned in the result set before sorting and thus rownum>0 means return no rows. Jim "Kin Ng" <kin_ng5 (AT) yahoo (DOT) com> wrote in message news:d5b3f600.0307121116.283114b1 (AT) posting (DOT) google.com... I have a complex query that takes a really long time to run and actually never completed because it ran out of space. But if I add this meaningless (oh well, may be meaningful) condition in the existing Where clause, the query returns data in a few seconds. and ROWNUM > 0 Why adding this makes a query run so much faster? |
#3
| |||
| |||
|
|
Actually the query returns LOTs of rows. It just took a long time (and err out) for a Large set of rows. I started trying to do ROWNUM = 1 and it returned FAST. Then I tried ROWNUM < 1000 and it returned a thousand rows fast. Then I tried ROWNUM < 10,000, then 1 million and finally ROWNUM > 0 and ALL cases it returned lots of rows and FAST. Why adding this makes a query run so much faster? |
#4
| |||
| |||
|
|
I have a complex query that takes a really long time to run and actually never completed because it ran out of space. But if I add this meaningless (oh well, may be meaningful) condition in the existing Where clause, the query returns data in a few seconds. and ROWNUM > 0 Why adding this makes a query run so much faster? |
#5
| |||
| |||
|
|
kin_ng5 (AT) yahoo (DOT) com (Kin Ng) wrote in message I have a complex query that takes a really long time to run and actually never completed because it ran out of space. But if I add this meaningless (oh well, may be meaningful) condition in the existing Where clause, the query returns data in a few seconds. and ROWNUM > 0 Why adding this makes a query run so much faster? As Daniel said, _always_ check your SQL via explain plan to see how Oracle will be executing it. As for adding the ROWNUM clause. I think that you are seeing the difference between an ALL_ROWS and FIRST_ROW execution. BTW, the query may likely _seem_ faster when it is not. With FIRST_ROW it returns the 1st set of results pretty quickly.. and while you are looking/processing those, Oracle gets the next set, and next... etc. However, doing an explain plan will show what's happening better than my guestimates. |
#6
| |||
| |||
|
|
Until my DBA fixed the Explain Plan problem (getting Plan table not setup error), I can tell you that when I changed the result to a single row Count(*), I still get much faster result (12 seconds vs 43 seconds). If I break the query into 2 parts by storing the result from the 1st part in a table and join the table with the 2nd part of the query and the result is fast without the RowNum > 0 clause. We are at 9.2 already so this isn't something old. snipped |
#7
| |||
| |||
|
|
I have a complex query that takes a really long time to run and actually never completed because it ran out of space. But if I add this meaningless (oh well, may be meaningful) condition in the existing Where clause, the query returns data in a few seconds. and ROWNUM > 0 Why adding this makes a query run so much faster? |
#8
| |||
| |||
|
|
Until my DBA fixed the Explain Plan problem (getting Plan table not setup error), I can tell you that when I changed the result to a single row Count(*), I still get much faster result (12 seconds vs 43 seconds). |
#9
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |