Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Optimising the Query
Charles Hooper wrote:
> pankaj_wolfhunter_at_yahoo.co.in wrote: >> Charles Hooper wrote:
>>>
>>>
>>>
>>>
>> Thanks for the replies. >> >> Here's the explain plan generated by the query: >> >> Execution Plan >> ---------------------------------------------------------- >> >> ------------------------------------------------------------------------------- >> ------------------------------- >> >> | Id | Operation | Name | >> Rows | >> Bytes | Cost | Pstart| Pstop | >> >> ------------------------------------------------------------------------------- >> ------------------------------- >> >> | 0 | SELECT STATEMENT | | >> 762K| >> 51M| 520K| | | >> >> | 1 | SORT ORDER BY | | >> 762K| >> 51M| 520K| | | >> >> | 2 | HASH GROUP BY | | >> 762K| >> 51M| 520K| | | >> >> | 3 | HASH JOIN RIGHT OUTER | | >> 1527K| >> 103M| 520K| | | >> >> | 4 | VIEW | | >> 36522 | >> 1248K| 251K| | | >> >> | 5 | HASH JOIN | | >> 36522 | >> 4529K| 251K| | | >> >> | 6 | VIEW | | >> 9583K| >> 539M| 79490 | | | >> >> | 7 | WINDOW SORT PUSHED RANK | | >> 9583K| >> 246M| 79490 | | | >> >> | 8 | PARTITION RANGE SINGLE | | >> 9583K| >> 246M| 10858 | 28 | 28 | >> >> | 9 | PARTITION HASH ALL | | >> 9583K| >> 246M| 10858 | 1 | 4 | >> >> | 10 | TABLE ACCESS FULL | TABLE2 | >> 9583K| >> 246M| 10858 | 109 | 112 | >> >> | 11 | VIEW | | >> 9434K| >> 611M| 109K| | | >> >> | 12 | WINDOW SORT PUSHED RANK | | >> 9434K| >> 224M| 109K| | | >> >> | 13 | PARTITION RANGE SINGLE | | >> 9434K| >> 224M| 44772 | 29 | 29 | >> >> | 14 | PARTITION HASH ALL | | >> 9434K| >> 224M| 44772 | 1 | 4 | >> >> | 15 | TABLE ACCESS FULL | TABLE3 | >> 9434K| >> 224M| 44772 | 113 | 116 | >> >> | 16 | PARTITION RANGE SINGLE | | >> 1527K| >> 52M| 269K| 30 | 30 | >> >> | 17 | PARTITION HASH ALL | | >> 1527K| >> 52M| 269K| 1 | 16 | >> >> | 18 | TABLE ACCESS BY LOCAL INDEX ROWID| TABLE1 | 1527K| >> 52M| 269K| 465 | 480 | >> >> | 19 | INDEX RANGE SCAN | TABLE1_P_UK1 | >> 46M| >> | 20636 | 465 | 480 | >> >> ------------------------------------------------------------------------------- >> ------------------------------- >> >> >> Note >> ----- >> - 'PLAN_TABLE' is old version >> >> >> Statistics >> ---------------------------------------------------------- >> 8199 recursive calls >> 8695 db block gets >> 1568210 consistent gets >> 1429061 physical reads >> 0 redo size >> 10581 bytes sent via SQL*Net to client >> 1203 bytes received via SQL*Net from client >> 36 SQL*Net roundtrips to/from client >> 51 sorts (memory) >> 2 sorts (disk) >> 514 rows processed > > Something that I missed in the original post that was made clear by the > explain plan: you have full table scans on TABLE2 and TABLE3. All rows > of TABLE2 are retrieved into a view (data is 539MB in size), and all > rows of TABLE3 are retrived into a view (data is 611MB in size), and > then the contents of these views are joined together using a hash join. > Only 1.2MB makes it out of the hash join, which is then joined with > TABLE1. The views that are generated are likely a result of the > (SELECT ... TABLE2) TAB2 syntax that you used. You have two sorts to > disk, which is possibly significant. You also have a high percentage > of physical reads compared to logical (consistent gets) reads. It is > unclear whether these physical reads are a result of the sort to disk. > > Compare the explain plan of your query with the explain plan for the > modified query that I posted. > > Charles Hooper > PC Support Specialist > K&M Machine-Fabricating, Inc.
And, in addition, do your future explain plans using DBMS_XPLAN ... not whatever script you are using. DBMS_XPLAN will give the amount of TEMP space used and other valuable information. Look at $ORACLE_HOME/rdbms/admin/utlxplp.sql.
Note also the "note" about plan_table being the old version. You should run catplan.sql (if available) and use the newest version.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Mon Nov 06 2006 - 12:06:42 CST
![]() |
![]() |