|
I have a procedure in a service program that I'd like to change to use SQL, but I can't seem to get my finger on how the index should look so the optimizer picks it up. Here is the SQL in the procedure. The select is actually a part of a declare. I'm fetching 250 rows at a time, and updating every row.
Select Cust#, CalDte, Pac#, Dept#, CalTyp, DstFlg, BAmt, DspQty,
Loc#, PrtFlg, SvPrtFlg, RRN(a)
From CdrMstP a
Where Cust# = :Cust# and CalDte <= :CutOff
and StmDte = '0001-01-01'
Order By Cust#, CalDte;
Update CdrMstP a
Set StmDte = :StmtDate,
Corp# = :Corp#,
Loc# = :ds_CdrOut.Loc#,
Dept# = :ds_CdrOut.Dept#,
PrtFlg = :ds_CdrOut.PrtFlg,
SvPrtFlg = :ds_CdrOut.SvPrtFlg
where rrn(a) = :ds_CDROut.CdrRRN;
Index attempts:
1. Doesn't like that a key field is getting updated.
CREATE INDEX CdrMst_x01
ON CdrMstP (Cust#, CalDte, Pac#, Dept#, CalTyp, DstFlg, BAmt, DspQty,
Loc#, PrtFlg, SvPrtFlg);
2. I think it doesn't like that my key doesn't include all the fields in the select
CREATE INDEX CdrMst_x01
ON CdrMstP (Cust#, CalDte)
Any thoughts?
I'm on v5r4.
Thanks,
Kurt Anderson
Sr. Programmer/Analyst
CustomCall Data Systems
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.