Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> (no subject)
Oracle 8.0.5
AIX 4.3.3
I Have following statement, which takes forever and does lots of physical
reads
SELECT v1.engagement, v1.YEAR, v1.period, MAX (v2.net_fee_earned_ptd) ,
MAX (v2.exp_wip_val_ptd) FROM (SELECT MAX (wstat.eng_numb) engagement, MAX (wstat.fnancl_year) YEAR, MAX (wstat.prd_numb) period, SUM (NVL (wstat.time_wip_val_ptd, 0)) + SUM (NVL (wstat.gnrl_w_on_ptd, 0))GROUP BY v1.engagement, v1.YEAR, v1.period /
- SUM (NVL (wstat.gnrl_w_off_ptd, 0))
- SUM (NVL (wstat.time_wip_val_w_off_ptd, 0))
- SUM (NVL (wstat.wip_prvsn_ptd, 0))
- SUM (NVL (wstat.exp_wip_val_w_off_ptd, 0))
- SUM (NVL (dstat.dbtrs_w_off_ptd, 0))
- SUM (NVL (dstat.dbtrs_prvsn_ptd, 0))
net_fee_earned_ptd, SUM (NVL (wstat.exp_wip_val_ptd, 0)) exp_wip_val_ptd FROM eng_wip_stats wstat, eng_dbtrs_stats dstat WHERE wstat.eng_numb(+) = dstat.eng_numb AND wstat.fnancl_year = dstat.fnancl_year AND wstat.prd_numb = dstat.prd_numb AND wstat.eng_numb = '1000001' GROUP BY wstat.eng_numb, wstat.fnancl_year, wstat.prd_numb) v1, (SELECT MAX (wstat.eng_numb) engagement, MAX (wstat.fnancl_year) YEAR, MAX (wstat.prd_numb) period, SUM (NVL (wstat.time_wip_val_ptd, 0)) + SUM (NVL (wstat.gnrl_w_on_ptd, 0))
- SUM (NVL (wstat.gnrl_w_off_ptd, 0))
- SUM (NVL (wstat.time_wip_val_w_off_ptd, 0))
- SUM (NVL (wstat.wip_prvsn_ptd, 0))
- SUM (NVL (wstat.exp_wip_val_w_off_ptd, 0))
- SUM (NVL (dstat.dbtrs_w_off_ptd, 0))
- SUM (NVL (dstat.dbtrs_prvsn_ptd, 0))
net_fee_earned_ptd, SUM (NVL (wstat.exp_wip_val_ptd, 0)) exp_wip_val_ptd FROM eng_wip_stats wstat, eng_dbtrs_stats dstat WHERE wstat.eng_numb(+) = dstat.eng_numb AND wstat.fnancl_year = dstat.fnancl_year AND wstat.prd_numb = dstat.prd_numb AND wstat.eng_numb = '1000001' GROUP BY wstat.eng_numb, wstat.fnancl_year, wstat.prd_numb) v2 WHERE v1.engagement = v2.engagement(+) AND TO_DATE ( v2.YEAR(+) || v2.period(+), 'YYYYMM') >= ADD_MONTHS (TO_DATE ( v1.YEAR || v1.period, 'YYYYMM'), -12) AND TO_DATE ( v2.YEAR(+) || v2.period(+), 'YYYYMM') <= TO_DATE ( v1.YEAR || v1.period, 'YYYYMM')
Here is the explain plan:
ID PID QUERY_PLAN
----- -----
0 INSERT STATEMENT Cost = 106 1 0 SORT GROUP BY Card=1 2 1 NESTED LOOPS OUTER Card=1 3 2 VIEW Card=1 4 3 SORT GROUP BY Card=1 5 4 HASH JOIN Card=1 6 5 TABLE ACCESS BY INDEX ROWID ENG_DBTRS_STATS Card=19 7 6 INDEX RANGE SCAN IDX_EG10_ENGNUMB_CRNTFLAG Card=19 8 5 TABLE ACCESS BY INDEX ROWID ENG_WIP_STATS Card=21 9 8 INDEX RANGE SCAN IDX_EG09_ENGNUMB_CRNTFLAG Card=21 10 2 VIEW Card=1 11 10 SORT GROUP BY Card=1 12 11 HASH JOIN Card=1 13 12 TABLE ACCESS BY INDEX ROWID ENG_DBTRS_STATS Card=19 14 13 INDEX RANGE SCAN IDX_EG10_ENGNUMB_CRNTFLAG Card=19 15 12 TABLE ACCESS BY INDEX ROWID ENG_WIP_STATS Card=21 16 15 INDEX RANGE SCAN IDX_EG09_ENGNUMB_CRNTFLAGCard=21
17 rows selected.
If I just run the select part (not insert into) it's really quick
With the following explain plan:
ID PID QUERY_PLAN
----- -----
0 SELECT STATEMENT Cost = 106 1 0 SORT GROUP BY Card=1 2 1 NESTED LOOPS OUTER Card=1 3 2 VIEW Card=1 4 3 SORT GROUP BY Card=1 5 4 HASH JOIN Card=1 6 5 TABLE ACCESS BY INDEX ROWID ENG_DBTRS_STATS Card=19 7 6 INDEX RANGE SCAN IDX_EG10_ENGNUMB_CRNTFLAG Card=19 8 5 TABLE ACCESS BY INDEX ROWID ENG_WIP_STATS Card=21 9 8 INDEX RANGE SCAN IDX_EG09_ENGNUMB_CRNTFLAG Card=21 10 2 VIEW Card=1 11 10 SORT GROUP BY Card=1 12 11 HASH JOIN Card=1 13 12 TABLE ACCESS BY INDEX ROWID ENG_DBTRS_STATS Card=19 14 13 INDEX RANGE SCAN IDX_EG10_ENGNUMB_CRNTFLAG Card=19 15 12 TABLE ACCESS BY INDEX ROWID ENG_WIP_STATS Card=21 16 15 INDEX RANGE SCAN IDX_EG09_ENGNUMB_CRNTFLAGCard=21
17 rows selected.
Apart from the word INSERT being replaced by SELECT I don't see why it would take so long. (no difference)
I turned tracing on and looked at the trace files for both statements and the difference seems to be only in "WAIT #1: nam='db file sequential read' ela= 0 p1=37 p2=127244 p3=1" which the insert into has many many many in th etrace file and the normal select only has few.( different numbers)
Anybody seen this before?? Know a solution??
Oh ja: If I do "create table as" it works really quick also
TIA Jack
Indien bovenstaand e-mailbericht niet aan u is gericht, verzoeken wij u vriendelijk doch dringend het e-mailbericht te retourneren aan de verzender en het origineel en eventuele kopieën te verwijderen en te vernietigen.
Ernst & Young hanteert bij de uitoefening van haar werkzaamheden algemene voorwaarden, waarin een beperking van aansprakelijkheid is opgenomen. De algemene voorwaarden worden u op verzoek kosteloos toegezonden.
If you are not the intended recipient of this communication please return the communication to the sender and delete and destroy all copies.
In carrying out its engagements, Ernst & Young applies general terms and conditions, which contain a clause that limits its liability. A copy of these terms and conditions is available on request free of charge.
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Jack van Zanen INET: nlzanen1_at_EY.NL Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Wed Aug 28 2002 - 08:58:51 CDT