Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: time consuming UPDATE statement
My hunch here would be that there are two problems:
Justin Cave
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
-----Original Message-----
From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Foelz.Frank
Sent: Friday, January 30, 2004 1:38 AM
To: 'oracle-l_at_freelists.org'
Subject: time consuming UPDATE statement
Hi Gurus,
sorry for the long posting, but I am kinda lost.........
In the below procedure, there is an Update Stement. This is so
timeconsuming, that the whole procedure takes 1 1/2 hrs to complete. If
the
UPDATE is removed, the whole thing is done in 3-4 mins. So there is
nothing
else eating up the time, but the Update....
BUT WHY ????????? I am on Oracle 7.3.4
Any hints are very welcome
Frank
Sellt Date, RateInc NUMBER(11), =20 Counter NUMBER(11), =20 Facility NUMBER(6), =20 GROSS_REV NUMBER(11), Validations NUMBER(11), constraint prim_MonTransRateInc primary key (Sellt,RateInc,Facility) using index storage ( initial 5M next 5M MAXEXTENTS 121 PCTINCREASE 50 ) tablespace report) storage ( initial 5M next 5M MAXEXTENTS 121 PCTINCREASE 10 ) tablespace report; ------------------------------------------------------------------------
Fetched BOOLEAN :=3D False;
CURSOR cur_move (EndDate DATE, maxlTotal number) IS
=09
SELECT tmov.class, tmov.artid, tmov.ZIDLOCAL, tmov.ZIDDEVICE, tmov.vouch, tmov.TOTAL, tmov.TOTQUA, trunc(tmov.sellt) SELLT, tmov.Attrib, tmov.Facility FROM shadow.tmovement tmov, shadow.tShift TS WHERE trunc(ts.tEndTime) between=20
AND LAST_DAY(trunc(EndDate)) and trunc(tmov.Sellt) between=20
AND LAST_DAY(trunc(EndDate)) AND mod(tmov.devid,65536) between 600 and 899 and ts.ZIDSHIFTLOCAL=3Dtmov.ZIDLOCAL and ts.ZIDSHIFTDEVICE=3Dtmov.ZIDDEVICE and bshiftState =3D 4 and trunc(sellt)=3Dto_date('01122003','ddmmyyyy') --and Total <=3D maxlTotal=20 ORDER BY tmov.zidlocal, tmov.ziddevice, tmov.vouch,tmov.Sellt, tmov.class, tmov.artid;
rec_move cur_move%ROWTYPE; rec_oldmove cur_move%ROWTYPE; rec_sum db.MonTransRateInc%ROWTYPE; BEGIN Delete from db.MonTransRateInc; OPEN cur_move(EndDate, maxlTotal); rec_sum.Sellt :=3Dto_date('01011977','ddmmyyyy'); rec_sum.RateInc :=3D0; rec_sum.Facility :=3D0; rec_sum.GROSS_REV :=3D0; rec_sum.Validations :=3D0; FETCH cur_move INTO rec_move; rec_oldMove:=3Drec_move; LOOP IF (rec_move.ZIDLOCAL <> rec_oldMove.ZIDLOCAL OR rec_move.ZIDDEVICE <> rec_oldMove.ZIDDEVICE OR rec_move.vouch <> rec_oldMove.vouch) OR (cur_move%NOTFOUND AND Fetched=3DTrue) THEN --dbms_output.put_line('U');
Fetched:=3DFalse; UpDate db.MonTransRateInc Set Counter13139
=3DCounter+rec_sum.Counter,
Gross_rev
=3DGross_Rev+rec_sum.Gross_rev,
Validations
=3DValiDations+rec_sum.validations
where Facility=3Drec_sum.Facility and trunc(Sellt)=3Dtrunc(Rec_Sum.Sellt) and RateInc=3DRec_sum.RateInc; If SQL%RowCount=3D0 then --dbms_output.put_line('I'); INSERT INTO db.MonTransRateInc (Sellt,=20 RateInc, Counter, Facility, GROSS_REV, Validations) VALUES (rec_sum.Sellt,=20 rec_sum.RateInc, rec_sum.Counter, rec_sum.Facility, rec_sum.Gross_rev, rec_sum.Validations); End If; rec_sum.RateInc:=3D0; rec_sum.Counter:=3D0; rec_sum.Facility:=3D-1; rec_sum.Gross_rev:=3D0; rec_sum.Validations:=3D0; rec_oldMove:=3Drec_move; end if; EXIT WHEN cur_move%NOTFOUND; IF rec_move.class in (0,1) THEN -- Gross Revenue Fetched:=3DTrue; rec_sum.gross_rev :=3D rec_sum.gross_rev + rec_move.total; rec_sum.Facility :=3Drec_move.Facility; rec_sum.RateInc :=3Drec_move.Total; rec_sum.Sellt :=3Drec_move.Sellt; rec_sum.Counter :=3Drec_move.TotQua; END IF; -- Coupons used=20 IF rec_move.class =3D 901 AND rec_move.ARTID !=3D 10 AND=20 rec_move.ARTID NOT between 13120 and
Fetched:=3DTrue; rec_sum.Validations :=3D rec_sum.Validations+
END IF;
--ISF used IF (rec_move.class =3D 901 AND rec_move.ARTID =3D 10 ) THEN Fetched:=3DTrue; rec_sum.Validations :=3D rec_sum.Validations + rec_move.total; =09 END IF; FETCH cur_move INTO rec_move; If Net=3DTrue then rec_sum.gross_rev :=3D rec_sum.gross_rev + rec_sum.Validations; rec_sum.RateInc :=3Drec_sum.RateInc+rec_sum.Validations; rec_sum.Validations:=3D0; End If; END LOOP; -- loop CLOSE cur_move; commit;
-- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html ----------------------------------------------------------------- ---------------------------------------------------------------- Please see the official ORACLE-L FAQ: http://www.orafaq.com ---------------------------------------------------------------- To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line. -- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------Received on Fri Jan 30 2004 - 02:57:39 CST
![]() |
![]() |