RGoo wrote:Спасибо всем за советы. Завтра буду пробовать предложенное.
P.S. #$% , а про хинты-то я забыл начисто
![Smile :)](./images/smilies/icon_smile.gif)
So far, the best piece of advice came from Dmitry67.
1. Firstly, you have to understand where your problem lies before trying to apply some random 'solutions' like hints, indexes, MVs and such.
2. Undoubtedly, if you process about 70% of the source table, any indexes are useless, at best.
3. On the practical side, you can run your SQL in the trace mode on some reasonable subset of the source data limiting the number of rows with a predicate (such as rownum <= 10000). Then, with the help from tkprof, you can obtain :
a. the execution statistics
a. the actual execution plan
b. the wait time break-down which will show on what events exactly the SQL spent its time.
E.g.:
Code: Select all
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.01 0 0 0 0
Execute 1 417.52 1914.01 2171938 1071811 21 78
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 417.53 1914.02 2171938 1071811 21 78
Rows Row Source Operation
------- ---------------------------------------------------
79 SORT GROUP BY
18939618 HASH JOIN
5505696 TABLE ACCESS FULL XX_ITEM
22492514 TABLE ACCESS FULL XX_INVENTORY PARTITION: START=12 STOP=12
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
file open 4 0.05 0.05
db file scattered read 26087 0.81 143.09
db file sequential read 770 0.08 0.26
direct path write 82283 0.43 63.17
latch free 144 0.02 1.46
direct path read 558661 1.05 1350.19
In this case, one can see that the bulk of the time was spent on reading the hash join results from the TEMP tablespace (direct path read). Probably increasing hash_area_size will help to decrease the amount of time spent on waiting for this event. Alternaively, re-writing the query may lead to a better execution plan.
... and so on...
Rgds.