Help in tuning.
I have a column called b_month and I its not an index column. But, in my query I need to apply a where clause on that column with some conditions like this.
and extract(month from b_month)=11
and extract(year from b_month)=2007
The table has approx 4 mil records. I changed the condition in this format:
and b_month = to_date('11/01/2007','MM/DD/YYYY')
Still there is no improvement in performance. IS there any other way to handle this apart from creating an index on that column.
Appreciate your feedback.
You have few options if you cannot add an index:
1) Partition the table by b_month
2) I assume you cannot create an index because you are concerned about impacting other queries. You could create a function-based index on this column turning it into a month number. Then other queries running against this table using the date will not use this index.
3) Add a /*+ parallel(table degree) */ hint to this query to speed up the full table scan. See:
http://www.singlequery.com/?p=49
Greg Pike
Similar Messages
-
Request for help in tuning the server which is running opmn process.
Hi Folks,
I request for an help in tuning the server which is running oracle app server opmn process , It is chewing arround 40% of the CPU resource,and our sysadmin is back of me to resolve this issues.
any feedback on this is highly appriciated...
Thanks in advanceRe: How to Achieve Performance Tuning
I hope you may find answers here..
Sharma -
Hi list ,
I need your help in tuning this sql.
Oracle 10g,Windows 2008 64 bit running on virtual machine.
SELECT t0.RecID, t0.PrtID, t0.RecOrdDt, t0.RecOrdID, t0.RecExtOrdID, t0.RecPocID, t0.PriID, t0.CasID, t0.CasNo, t0.CasClass, t0.CasPocID, t0.CasAdmit, t0.CasNotValid, t0.PatName, t0.PatFName, t0.PatBName, t0.PatBDate, t0.PatSex, t0.PatNotValid, t0.RstID, t0.RstState, t0.RstMeaningI18N, t0.PrtType, t0.PrtSubType, t0.RpxType, t0.RpxPrio, t0.PerID, t0.PerName, t0.PerFName, t0.PerTitle, t0.PerType, t0.AgnExtID
FROM
IXSERV.XsvRecPerInfoV t0
WHERE
((((t0.AgnExtID = '1728454694') AND (t0.PrtID IN (72, 165)))
AND (t0.RpxType IN (1, 2, 6, 3, 5)))
AND (t0.RstState IN (202, 208, 210, 203, 206)))
call count cpu elapsed disk query current rows
Parse 1 0.04 0.03 0 1999 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 4 5.39 57.42 45408 53080 0 45
total 6 5.43 57.46 45408 55079 0 45
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Rows Row Source Operation
45 NESTED LOOPS (cr=53080 pr=45408 pw=0 time=2611987 us)
45 NESTED LOOPS (cr=52941 pr=45355 pw=0 time=46145568 us)
45 HASH JOIN (cr=52802 pr=45314 pw=0 time=45407144 us)
1 TABLE ACCESS BY INDEX ROWID PERPERSON (cr=3 pr=6 pw=0 time=40510 us)
1 INDEX RANGE SCAN PERIDXAGNEXTID (cr=2 pr=5 pw=0 time=22311 us)(object id 56817)
23623 TABLE ACCESS BY INDEX ROWID XSVRECPERXREF (cr=52799 pr=45308 pw=0 time=50046345 us)
33893 NESTED LOOPS (cr=47543 pr=42261 pw=0 time=73003406 us)
5139 HASH JOIN (cr=37184 pr=40103 pw=0 time=56090695 us)
5 TABLE ACCESS FULL XMFREPORTSTATE (cr=7 pr=6 pw=0 time=22565 us)
66900 TABLE ACCESS BY INDEX ROWID XSVPATIENTRECORD (cr=37177 pr=40097 pw=0 time=39887547 us)
66903 NESTED LOOPS (cr=146 pr=141 pw=0 time=8095232 us)
2 INLIST ITERATOR (cr=4 pr=3 pw=0 time=37200 us)
2 TABLE ACCESS BY INDEX ROWID XMFPATIENTRECORDTYPE (cr=4 pr=3 pw=0 time=37198 us)
2 INDEX UNIQUE SCAN PKPRT (cr=2 pr=1 pw=0 time=26746 us)(object id 56143)
66900 INDEX RANGE SCAN RECIDXPRTID (cr=142 pr=138 pw=0 time=51513 us)(object id 56410)
28753 INDEX RANGE SCAN RPXIDXRECID (cr=10359 pr=2158 pw=0 time=4518986 us)(object id 56453)
45 TABLE ACCESS BY INDEX ROWID ADTCASE (cr=139 pr=41 pw=0 time=423483 us)
45 INDEX UNIQUE SCAN PK_ADTCASE (cr=94 pr=23 pw=0 time=184866 us)(object id 55295)
45 TABLE ACCESS BY INDEX ROWID ADTPATIENT (cr=139 pr=53 pw=0 time=413067 us)
45 INDEX UNIQUE SCAN PK_ADTPATIENT (cr=94 pr=21 pw=0 time=195583 us)(object id 55361)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net break/reset to client 2 0.00 0.00
SQL*Net message to client 5 0.00 0.00
SQL*Net message from client 5 114.42 128.67
SQL*Net more data to client 1 0.00 0.00
db file sequential read 27969 0.13 51.57
db file scattered read 3271 0.05 4.61
Some lines from trace fils :
WAIT #1: nam='db file sequential read' ela= 12778 file#=4 block#=3726132 blocks=1 obj#=56817 tim=249799016372
WAIT #1: nam='db file scattered read' ela= 9271 file#=4 block#=3726133 blocks=4 obj#=56817 tim=249799025761
WAIT #1: nam='db file sequential read' ela= 18141 file#=4 block#=587487 blocks=1 obj#=55853 tim=249799043945
WAIT #1: nam='db file sequential read' ela= 18304 file#=4 block#=752595 blocks=1 obj#=56219 tim=249799062471
and the view XsvRecPerInfoV is :
SELECT d.RecID, d.PrtID, d.RecOrdDt, d.RecOrdID, d.RecExtOrdID, d.PocID, d.PriID, c.CasID, c. CasNo, c.CasClass, c.PocID, c.CasAdmit, c.CasNotValid, p.PatName, p.PatFName, p.PatBName, p.PatBDate, p.PatSex, p.PatNotValid, r.RstID, r.RstState, r.RstMeaningI18N, prt.PrtType, prt.PrtSubType, x.RpxType, x.RpxPrio, per.PerID, per.PerName, per.PerFName, per.PerTitle, per.PerType, per.AgnExtID
FROM XsvPatientRecord d,
AdtCase c,
AdtPatient p,
XmfReportState r,
XmfPatientRecordType prt,
XsvRecPerXRef x,
PerPerson per
WHERE
d.RecID = x.RecID
AND d.RstID = r.RstID
AND d.PrtID = prt.PrtID
AND d.CasID = c.CasID
AND x.PerID = per.PerID
AND c.PatID = p.PatID
i have two questions :
-1 The problem in tables XSVPATIENTRECORD and XSVRECPERXREF so how can i speed this query either by rewriting it or indexs?
-2 is my system i-o is slow ?
Best wishes
Edited by: welo on Oct 6, 2010 5:05 AMhi ,
it did not work with dynamic samplying. I am posting here trace 10053 output for the correct plan and wrong plan choosed but the optimizer i need soome one to help me in understanding why the optimizer is choosing wrong join order.
Sql statement and wrong plan :
tageCurrent SQL statement for this session:
SELECT t0.RecID, t0.PrtID, t0.RecOrdDt, t0.RecOrdID, t0.RecExtOrdID, t0.RecPocID, t0.PriID, t0.CasID, t0.CasNo, t0.CasClass, t0.CasPocID, t0.CasAdmit, t0.CasNotValid, t0.PatName, t0.PatFName, t0.PatBName, t0.PatBDate, t0.PatSex, t0.PatNotValid, t0.RstID, t0.RstState, t0.RstMeaningI18N, t0.PrtType, t0.PrtSubType, t0.RpxType, t0.RpxPrio, t0.PerID, t0.PerName, t0.PerFName, t0.PerTitle, t0.PerType, t0.AgnExtID
FROM XsvRecPerInfoV t0
WHERE
((((t0.AgnExtID = '1393621382') AND (t0.PrtID IN (72, 165))) AND (t0.RpxType IN (1, 2, 6, 3, 5))) AND (t0.RstState IN (202, 208, 210, 203, 206)))
--------------------------------------------------------------------+-----------------------------------+
| Id | Operation | Name | Rows | Bytes | Cost | Time |
--------------------------------------------------------------------+-----------------------------------+
| 0 | SELECT STATEMENT | | | | 842 | |
| 1 | NESTED LOOPS | | 1 | 204 | 842 | 00:00:11 |
| 2 | NESTED LOOPS | | 1 | 163 | 840 | 00:00:11 |
| 3 | HASH JOIN | | 1 | 129 | 838 | 00:00:11 |
| 4 | TABLE ACCESS BY INDEX ROWID | PERPERSON | 1 | 29 | 2 | 00:00:01 |
| 5 | INDEX RANGE SCAN | PERIDXAGNEXTID | 1 | | 1 | 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID | XSVRECPERXREF | 2 | 34 | 3 | 00:00:01 |
| 7 | NESTED LOOPS | | 379 | 37K | 835 | 00:00:11 |
| 8 | HASH JOIN | | 238 | 19K | 342 | 00:00:05 |
| 9 | TABLE ACCESS FULL | XMFREPORTSTATE | 5 | 65 | 3 | 00:00:01 |
| 10 | TABLE ACCESS BY INDEX ROWID | XSVPATIENTRECORD | 524 | 30K | 218 | 00:00:03 |
| 11 | NESTED LOOPS | | 1049 | 72K | 338 | 00:00:05 |
| 12 | INLIST ITERATOR | | | | | |
| 13 | TABLE ACCESS BY INDEX ROWID | XMFPATIENTRECORDTYPE| 2 | 22 | 2 | 00:00:01 |
| 14 | INDEX UNIQUE SCAN | PKPRT | 2 | | 1 | 00:00:01 |
| 15 | INDEX RANGE SCAN | RECIDXPRTID | 524 | | 119 | 00:00:02 |
| 16 | INDEX RANGE SCAN | RPXIDXRECID | 2 | | 2 | 00:00:01 |
| 17 | TABLE ACCESS BY INDEX ROWID | ADTCASE | 1 | 34 | 2 | 00:00:01 |
| 18 | INDEX UNIQUE SCAN | PK_ADTCASE | 1 | | 1 | 00:00:01 |
| 19 | TABLE ACCESS BY INDEX ROWID | ADTPATIENT | 1 | 41 | 2 | 00:00:01 |
| 20 | INDEX UNIQUE SCAN | PK_ADTPATIENT | 1 | | 1 | 00:00:01 |
--------------------------------------------------------------------+-----------------------------------+
3 - access("PER"."PERID"="X"."PERID")
5 - access("PER"."AGNEXTID"='1393621382')
6 - filter(("X"."RPXTYPE"=1 OR "X"."RPXTYPE"=2 OR "X"."RPXTYPE"=3 OR "X"."RPXTYPE"=5 OR "X"."RPXTYPE"=6))
8 - access("D"."RSTID"="R"."RSTID")
9 - filter(("R"."RSTSTATE"=202 OR "R"."RSTSTATE"=203 OR "R"."RSTSTATE"=206 OR "R"."RSTSTATE"=208 OR "R"."RSTSTATE"=210))
14 - access(("PRT"."PRTID"=72 OR "PRT"."PRTID"=165))
15 - access("D"."PRTID"="PRT"."PRTID")
15 - filter(("D"."PRTID"=72 OR "D"."PRTID"=165))
16 - access("X"."RECID"="D"."RECID")
18 - access("D"."CASID"="C"."CASID")
20 - access("C"."PATID"="P"."PATID")
Join order[7]: XMFPATIENTRECORDTYPE[PRT]#1 XSVPATIENTRECORD[D]#3 XMFREPORTSTATE[R]#2 XSVRECPERXREF[X]#5 PERPERSON[PER]#0 ADTCASE[C]#6 ADTPATIENT[P]#4
Now joining: XSVPATIENTRECORD[D]#3
NL Join
Outer table: Card: 2.00 Cost: 2.00 Resp: 2.00 Degree: 1 Bytes: 11
Inner table: XSVPATIENTRECORD Alias: D
Access Path: TableScan
NL Join: Cost: 53601.79 Resp: 53601.79 Degree: 1
Cost_io: 53336.00 Cost_cpu: 7967475433
Resp_io: 53336.00 Resp_cpu: 7967475433
kkofmx: index filter:
("D"."PRTID"=72 OR "D"."PRTID"=165) AND ("X"."RPXTYPE"=1 OR "X"."RPXTYPE"=2 OR "X"."RPXTYPE"=3 OR "X"."RPXTYPE"=5 OR "X"."RPXTYPE"=6) AND ("R"."RSTSTATE"=202 OR "R"."RSTSTATE"=203 OR "R"."RSTSTATE"=206 OR "R"."RSTSTATE"=208 OR "R"."RSTSTATE"=210) AND "PER"."PERID"="X"."PERID" AND "X"."RECID"="D"."RECID" AND "D"."RSTID"="R"."RSTID" AND "D"."PRTID"="PRT"."PRTID" AND "D"."CASID"="C"."CASID" AND "C"."PATID"="P"."PATID" AND ("PRT"."PRTID"=72 OR "PRT"."PRTID"=165)
kkofmx: index filter:"D"."PRTID"="PRT"."PRTID" AND "D"."CASID"="C"."CASID" AND "C"."PATID"="P"."PATID" AND ("PRT"."PRTID"=72 OR "PRT"."PRTID"=165)
kkofmx: index filter:
("D"."PRTID"=72 OR "D"."PRTID"=165) AND ("X"."RPXTYPE"=1 OR "X"."RPXTYPE"=2 OR "X"."RPXTYPE"=3 OR "X"."RPXTYPE"=5 OR "X"."RPXTYPE"=6) AND ("R"."RSTSTATE"=202 OR "R"."RSTSTATE"=203 OR "R"."RSTSTATE"=206 OR "R"."RSTSTATE"=208 OR "R"."RSTSTATE"=210) AND "PER"."PERID"="X"."PERID" AND "X"."RECID"="D"."RECID" AND "D"."RSTID"="R"."RSTID" AND "D"."PRTID"="PRT"."PRTID" AND "D"."CASID"="C"."CASID" AND "C"."PATID"="P"."PATID" AND ("PRT"."PRTID"=72 OR "PRT"."PRTID"=165)
Access Path: index (FullScan)
Index: IRECRECORDIDPRTID
resc_io: 43172.00 resc_cpu: 2118737558
ix_sel: 1 ix_sel_with_filters: 6.2392e-005
NL Join: Cost: 86121.14 Resp: 86121.14 Degree: 1
Cost_io: 85924.00 Cost_cpu: 5909611610
Resp_io: 85924.00 Resp_cpu: 5909611610
Access Path: index (AllEqJoinGuess)
Index: RECIDXPRTID
resc_io: 217.00 resc_cpu: 13774732
ix_sel: 0.0074074 ix_sel_with_filters: 6.2392e-005
NL Join (ordered): Cost: 338.30 Resp: 338.30 Degree: 1
Cost_io: 337.00 Cost_cpu: 39079056
Resp_io: 337.00 Resp_cpu: 39079056
****** trying bitmap/domain indexes ******
****** finished trying bitmap/domain indexes ******
Best NL cost: 338.30
resc: 338.30 resc_io: 337.00 resc_cpu: 39079056
resp: 338.30 resp_io: 337.00 resp_cpu: 39079056
Join Card: 1048.85 = outer (2.00) * inner (70797.49) * sel (0.0074074)
Join Card - Rounded: 1049 Computed: 1048.85
SM Join
Outer table:
resc: 2.00 card 2.00 bytes: 11 deg: 1 resp: 2.00
Inner table: XSVPATIENTRECORD Alias: D
resc: 13387.34 card: 70797.49 bytes: 59 deg: 1 resp: 13387.34
using dmeth: 2 #groups: 1
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 651 Row size: 75 Total Rows: 70797
Initial runs: 2 Merge passes: 1 IO Cost / pass: 354
Total IO sort cost: 1005 Total CPU sort cost: 97398867
Total Temp space used: 11969000
SM join: Resc: 14397.59 Resp: 14397.59 [multiMatchCost=0.00]
SM cost: 14397.59
resc: 14397.59 resc_io: 14389.81 resc_cpu: 233098276
resp: 14397.59 resp_io: 14389.81 resp_cpu: 233098276
HA Join
Outer table:
resc: 2.00 card 2.00 bytes: 11 deg: 1 resp: 2.00
Inner table: XSVPATIENTRECORD Alias: D
resc: 13387.34 card: 70797.49 bytes: 59 deg: 1 resp: 13387.34
using dmeth: 2 #groups: 1
Cost per ptn: 0.74 #ptns: 1
hash_area: 124 (max=19098) buildfrag: 1 probefrag: 614 ppasses: 1
Hash join: Resc: 13390.08 Resp: 13390.08 [multiMatchCost=0.00]
HA cost: 13390.08
resc: 13390.08 resc_io: 13384.81 resc_cpu: 157767585
resp: 13390.08 resp_io: 13384.81 resp_cpu: 157767585
Best:: JoinMethod: NestedLoop
Cost: 338.30 Degree: 1 Resp: 338.30 Card: 1048.85 Bytes: 70
Now joining: XMFREPORTSTATE[R]#2
NL Join
Outer table: Card: 1048.85 Cost: 338.30 Resp: 338.30 Degree: 1 Bytes: 70
Inner table: XMFREPORTSTATE Alias: R
Access Path: TableScan
NL Join: Cost: 1489.04 Resp: 1489.04 Degree: 1
Cost_io: 1486.00 Cost_cpu: 91090703
Resp_io: 1486.00 Resp_cpu: 91090703
Access Path: index (UniqueScan)
Index: PK_XMFREPORTSTATE
resc_io: 1.00 resc_cpu: 8697
ix_sel: 0.030303 ix_sel_with_filters: 0.030303
NL Join: Cost: 1387.61 Resp: 1387.61 Degree: 1
Cost_io: 1386.00 Cost_cpu: 48201937
Resp_io: 1386.00 Resp_cpu: 48201937
Access Path: index (AllEqUnique)
Index: PK_XMFREPORTSTATE
resc_io: 1.00 resc_cpu: 8697
ix_sel: 0.030303 ix_sel_with_filters: 0.030303
NL Join: Cost: 1387.61 Resp: 1387.61 Degree: 1
Cost_io: 1386.00 Cost_cpu: 48201937
Resp_io: 1386.00 Resp_cpu: 48201937
****** trying bitmap/domain indexes ******
****** finished trying bitmap/domain indexes ******
Best NL cost: 1387.61
resc: 1387.61 resc_io: 1386.00 resc_cpu: 48201937
resp: 1387.61 resp_io: 1386.00 resp_cpu: 48201937
Join Card: 238.38 = outer (1048.85) * inner (5.00) * sel (0.045455)
Join Card - Rounded: 238 Computed: 238.38
SM Join
Outer table:
resc: 338.30 card 1048.85 bytes: 70 deg: 1 resp: 338.30
Inner table: XMFREPORTSTATE Alias: R
resc: 3.00 card: 5.00 bytes: 13 deg: 1 resp: 3.00
using dmeth: 2 #groups: 1
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 12 Row size: 87 Total Rows: 1049
Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
Total IO sort cost: 0 Total CPU sort cost: 30450620
Total Temp space used: 0
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 1 Row size: 25 Total Rows: 5
Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
Total IO sort cost: 0 Total CPU sort cost: 29976876
Total Temp space used: 0
SM join: Resc: 343.32 Resp: 343.32 [multiMatchCost=0.00]
SM cost: 343.32
resc: 343.32 resc_io: 340.00 resc_cpu: 99556133
resp: 343.32 resp_io: 340.00 resp_cpu: 99556133
HA Join
Outer table:
resc: 338.30 card 1048.85 bytes: 70 deg: 1 resp: 338.30
Inner table: XMFREPORTSTATE Alias: R
resc: 3.00 card: 5.00 bytes: 13 deg: 1 resp: 3.00
using dmeth: 2 #groups: 1
Cost per ptn: 0.51 #ptns: 1
hash_area: 124 (max=19098) buildfrag: 11 probefrag: 1 ppasses: 1
Hash join: Resc: 341.81 Resp: 341.81 [multiMatchCost=0.00]
HA Join (swap)
Outer table:
resc: 3.00 card 5.00 bytes: 13 deg: 1 resp: 3.00
Inner table: XSVPATIENTRECORD Alias: D
resc: 338.30 card: 1048.85 bytes: 70 deg: 1 resp: 338.30
using dmeth: 2 #groups: 1
Cost per ptn: 0.50 #ptns: 1
hash_area: 124 (max=19098) buildfrag: 1 probefrag: 11 ppasses: 1
Hash join: Resc: 341.81 Resp: 341.81 [multiMatchCost=0.00]
HA cost: 341.81
resc: 341.81 resc_io: 340.00 resc_cpu: 54222464
resp: 341.81 resp_io: 340.00 resp_cpu: 54222464
Best:: JoinMethod: Hash
Cost: 341.81 Degree: 1 Resp: 341.81 Card: 238.38 Bytes: 83
Now joining: XSVRECPERXREF[X]#5
NL Join
Outer table: Card: 238.38 Cost: 341.81 Resp: 341.81 Degree: 1 Bytes: 83
Inner table: XSVRECPERXREF Alias: X
Access Path: TableScan
NL Join: Cost: 280914.52 Resp: 280914.52 Degree: 1
Cost_io: 275752.00 Cost_cpu: 154753663635
Resp_io: 275752.00 Resp_cpu: 154753663635
kkofmx: index filter:
("X"."RPXTYPE"=1 OR "X"."RPXTYPE"=2 OR "X"."RPXTYPE"=3 OR "X"."RPXTYPE"=5 OR "X"."RPXTYPE"=6) AND ("R"."RSTSTATE"=202 OR "R"."RSTSTATE"=203 OR "R"."RSTSTATE"=206 OR "R"."RSTSTATE"=208 OR "R"."RSTSTATE"=210) AND "PER"."PERID"="X"."PERID" AND "X"."RECID"="D"."RECID" AND "D"."RSTID"="R"."RSTID" AND "D"."PRTID"="PRT"."PRTID" AND "D"."CASID"="C"."CASID" AND "C"."PATID"="P"."PATID" AND ("PRT"."PRTID"=72 OR "PRT"."PRTID"=165)
Access Path: index (AllEqJoinGuess)
Index: RPXIDXRECID
resc_io: 3.00 resc_cpu: 23984
ix_sel: 1.6577e-006 ix_sel_with_filters: 1.6577e-006
NL Join: Cost: 835.02 Resp: 835.02 Degree: 1
Cost_io: 833.08 Cost_cpu: 58098995
Resp_io: 833.08 Resp_cpu: 58098995
Access Path: index (RangeScan)
Index: URPXRECPERTYPE
resc_io: 3.00 resc_cpu: 23274
ix_sel: 1.6577e-006 ix_sel_with_filters: 9.4822e-007
NL Join: Cost: 835.02 Resp: 835.02 Degree: 1
Cost_io: 833.08 Cost_cpu: 58181005
Resp_io: 833.08 Resp_cpu: 58181005
****** trying bitmap/domain indexes ******
****** finished trying bitmap/domain indexes ******
Best NL cost: 835.02
resc: 835.02 resc_io: 833.08 resc_cpu: 58098995
resp: 835.02 resp_io: 833.08 resp_cpu: 58098995
Join Card: 378.67 = outer (238.38) * inner (835508.80) * sel (1.9013e-006)
Join Card - Rounded: 379 Computed: 378.67
SM Join
Outer table:
resc: 341.81 card 238.38 bytes: 83 deg: 1 resp: 341.81
Inner table: XSVRECPERXREF Alias: X
resc: 1180.68 card: 835508.80 bytes: 17 deg: 1 resp: 1180.68
using dmeth: 2 #groups: 1
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 3 Row size: 102 Total Rows: 238
Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
Total IO sort cost: 0 Total CPU sort cost: 30061009
Total Temp space used: 0
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 2967 Row size: 29 Total Rows: 835509
Initial runs: 2 Merge passes: 1 IO Cost / pass: 1608
Total IO sort cost: 4575 Total CPU sort cost: 843575684
Total Temp space used: 53699000
SM join: Resc: 6126.64 Resp: 6126.64 [multiMatchCost=0.00]
SM cost: 6126.64
resc: 6126.64 resc_io: 6074.00 resc_cpu: 1577856809
resp: 6126.64 resp_io: 6074.00 resp_cpu: 1577856809
HA Join
Outer table:
resc: 341.81 card 238.38 bytes: 83 deg: 1 resp: 341.81
Inner table: XSVRECPERXREF Alias: X
resc: 1180.68 card: 835508.80 bytes: 17 deg: 1 resp: 1180.68
using dmeth: 2 #groups: 1
Cost per ptn: 3.29 #ptns: 1
hash_area: 124 (max=19098) buildfrag: 3 probefrag: 2958 ppasses: 1
Hash join: Resc: 1525.78 Resp: 1525.78 [multiMatchCost=0.00]
HA cost: 1525.78
resc: 1525.78 resc_io: 1499.00 resc_cpu: 802794893
resp: 1525.78 resp_io: 1499.00 resp_cpu: 802794893
Best:: JoinMethod: NestedLoop
Cost: 835.02 Degree: 1 Resp: 835.02 Card: 378.67 Bytes: 100
Now joining: PERPERSON[PER]#0
NL Join
Outer table: Card: 378.67 Cost: 835.02 Resp: 835.02 Degree: 1 Bytes: 100
Inner table: PERPERSON Alias: PER
Access Path: TableScan
NL Join: Cost: 409701.78 Resp: 409701.78 Degree: 1
Cost_io: 408070.08 Cost_cpu: 48912477468
Resp_io: 408070.08 Resp_cpu: 48912477468
Access Path: index (UniqueScan)
Index: PKPER
resc_io: 2.00 resc_cpu: 16603
ix_sel: 2.7682e-006 ix_sel_with_filters: 2.7682e-006
NL Join: Cost: 1593.23 Resp: 1593.23 Degree: 1
Cost_io: 1591.08 Cost_cpu: 64391486
Resp_io: 1591.08 Resp_cpu: 64391486
Access Path: index (AllEqJoin)
Index: PERIDXAGNEXTID
resc_io: 2.00 resc_cpu: 15703
ix_sel: 0.001065 ix_sel_with_filters: 0.001065
NL Join: Cost: 1593.22 Resp: 1593.22 Degree: 1
Cost_io: 1591.08 Cost_cpu: 64050386
Resp_io: 1591.08 Resp_cpu: 64050386
Access Path: index (AllEqUnique)
Index: PKPER
resc_io: 2.00 resc_cpu: 16603
ix_sel: 2.7682e-006 ix_sel_with_filters: 2.7682e-006
NL Join: Cost: 1593.23 Resp: 1593.23 Degree: 1
Cost_io: 1591.08 Cost_cpu: 64391486
Resp_io: 1591.08 Resp_cpu: 64391486
****** trying bitmap/domain indexes ******
Access Path: index (AllEqJoin)
Index: PERIDXAGNEXTID
resc_io: 1.00 resc_cpu: 8171
ix_sel: 0.001065 ix_sel_with_filters: 0.001065
NL Join: Cost: 1214.12 Resp: 1214.12 Degree: 1
Cost_io: 1212.08 Cost_cpu: 61195971
Resp_io: 1212.08 Resp_cpu: 61195971
Access Path: index (AllEqUnique)
Index: PKPER
resc_io: 1.00 resc_cpu: 9021
ix_sel: 2.7682e-006 ix_sel_with_filters: 2.7682e-006
NL Join: Cost: 1214.13 Resp: 1214.13 Degree: 1
Cost_io: 1212.08 Cost_cpu: 61518121
Resp_io: 1212.08 Resp_cpu: 61518121
Access path: Bitmap index - rejected
Cost: 3293.30 Cost_io: 3287.25 Cost_cpu: 181295210 Sel: 9.5086e-007
Not believed to be index-only
****** finished trying bitmap/domain indexes ******
Best NL cost: 1593.22
resc: 1593.22 resc_io: 1591.08 resc_cpu: 64050386
resp: 1593.22 resp_io: 1591.08 resp_cpu: 64050386
Join Card: 0.34 = outer (378.67) * inner (1.00) * sel (8.9286e-004)
Join Card - Rounded: 1 Computed: 0.34
SM Join
Outer table:
resc: 835.02 card 378.67 bytes: 100 deg: 1 resp: 835.02
Inner table: PERPERSON Alias: PER
resc: 2.00 card: 1.00 bytes: 29 deg: 1 resp: 2.00
using dmeth: 2 #groups: 1
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 6 Row size: 120 Total Rows: 379
Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
Total IO sort cost: 0 Total CPU sort cost: 30122624
Total Temp space used: 0
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 1 Row size: 42 Total Rows: 1
Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
Total IO sort cost: 0 Total CPU sort cost: 29976353
Total Temp space used: 0
SM join: Resc: 839.02 Resp: 839.02 [multiMatchCost=0.00]
SM cost: 839.02
resc: 839.02 resc_io: 835.08 resc_cpu: 118213674
resp: 839.02 resp_io: 835.08 resp_cpu: 118213674
HA Join
Outer table:
resc: 835.02 card 378.67 bytes: 100 deg: 1 resp: 835.02
Inner table: PERPERSON Alias: PER
resc: 2.00 card: 1.00 bytes: 29 deg: 1 resp: 2.00
using dmeth: 2 #groups: 1
Cost per ptn: 0.50 #ptns: 1
hash_area: 124 (max=19098) buildfrag: 6 probefrag: 1 ppasses: 1
Hash join: Resc: 837.52 Resp: 837.52 [multiMatchCost=0.00]
HA Join (swap)
Outer table:
resc: 2.00 card 1.00 bytes: 29 deg: 1 resp: 2.00
Inner table: XSVRECPERXREF Alias: X
resc: 835.02 card: 378.67 bytes: 100 deg: 1 resp: 835.02
using dmeth: 2 #groups: 1
Cost per ptn: 0.50 #ptns: 1
hash_area: 124 (max=19098) buildfrag: 1 probefrag: 6 ppasses: 1
Hash join: Resc: 837.52 Resp: 837.52 [multiMatchCost=0.00]
HA cost: 837.52
resc: 837.52 resc_io: 835.08 resc_cpu: 73140924
resp: 837.52 resp_io: 835.08 resp_cpu: 73140924
Best:: JoinMethod: Hash
Cost: 837.52 Degree: 1 Resp: 837.52 Card: 0.34 Bytes: 129
Now joining: ADTCASE[C]#6
NL Join
Outer table: Card: 0.34 Cost: 837.52 Resp: 837.52 Degree: 1 Bytes: 129
Inner table: ADTCASE Alias: C
Access Path: TableScan
NL Join: Cost: 6458.89 Resp: 6458.89 Degree: 1
Cost_io: 6414.08 Cost_cpu: 1343349671
Resp_io: 6414.08 Resp_cpu: 1343349671
Access Path: index (UniqueScan)
Index: PK_ADTCASE
resc_io: 2.00 resc_cpu: 16573
ix_sel: 3.9499e-007 ix_sel_with_filters: 3.9499e-007
NL Join: Cost: 839.52 Resp: 839.52 Degree: 1
Cost_io: 837.08 Cost_cpu: 73157497
Resp_io: 837.08 Resp_cpu: 73157497
Access Path: index (AllEqUnique)
Index: PK_ADTCASE
resc_io: 2.00 resc_cpu: 16573
ix_sel: 3.9478e-007 ix_sel_with_filters: 3.9478e-007
NL Join: Cost: 839.52 Resp: 839.52 Degree: 1
Cost_io: 837.08 Cost_cpu: 73157497
Resp_io: 837.08 Resp_cpu: 73157497
****** trying bitmap/domain indexes ******
****** finished trying bitmap/domain indexes ******
Best NL cost: 839.52
resc: 839.52 resc_io: 837.08 resc_cpu: 73157497
resp: 839.52 resp_io: 837.08 resp_cpu: 73157497
Join Card: 0.34 = outer (0.34) * inner (2531689.00) * sel (3.9478e-007)
Join Card - Rounded: 1 Computed: 0.34
SM Join
Outer table:
resc: 837.52 card 0.34 bytes: 129 deg: 1 resp: 837.52
Inner table: ADTCASE Alias: C
resc: 5621.37 card: 2531689.00 bytes: 34 deg: 1 resp: 5621.37
using dmeth: 2 #groups: 1
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 1 Row size: 152 Total Rows: 1
Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
Total IO sort cost: 0 Total CPU sort cost: 29976353
Total Temp space used: 0
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 14878 Row size: 48 Total Rows: 2531689
Initial runs: 2 Merge passes: 1 IO Cost / pass: 8060
Total IO sort cost: 22938 Total CPU sort cost: 2822696818
Total Temp space used: 264217000
SM join: Resc: 29492.06 Resp: 29492.06 [multiMatchCost=0.00]
SM cost: 29492.06
resc: 29492.06 resc_io: 29352.08 resc_cpu: 4196022842
resp: 29492.06 resp_io: 29352.08 resp_cpu: 4196022842
HA Join
Outer table:
resc: 837.52 card 0.34 bytes: 129 deg: 1 resp: 837.52
Inner table: ADTCASE Alias: C
resc: 5621.37 card: 2531689.00 bytes: 34 deg: 1 resp: 5621.37
using dmeth: 2 #groups: 1
Cost per ptn: 8.95 #ptns: 1
hash_area: 124 (max=19098) buildfrag: 1 probefrag: 14217 ppasses: 1
Hash join: Resc: 6467.84 Resp: 6467.84 [multiMatchCost=0.00]
HA cost: 6467.84
resc: 6467.84 resc_io: 6414.08 resc_cpu: 1611506897
resp: 6467.84 resp_io: 6414.08 resp_cpu: 1611506897
Best:: JoinMethod: NestedLoop
Cost: 839.52 Degree: 1 Resp: 839.52 Card: 0.34 Bytes: 163
Now joining: ADTPATIENT[P]#4
NL Join
Outer table: Card: 0.34 Cost: 839.52 Resp: 839.52 Degree: 1 Bytes: 163
Inner table: ADTPATIENT Alias: P
Access Path: TableScan
NL Join: Cost: 2172.07 Resp: 2172.07 Degree: 1
Cost_io: 2161.08 Cost_cpu: 329395913
Resp_io: 2161.08 Resp_cpu: 329395913
Access Path: index (UniqueScan)
Index: PK_ADTPATIENT
resc_io: 2.00 resc_cpu: 16533
ix_sel: 1.8294e-006 ix_sel_with_filters: 1.8294e-006
NL Join: Cost: 841.52 Resp: 841.52 Degree: 1
Cost_io: 839.08 Cost_cpu: 73174030
Resp_io: 839.08 Resp_cpu: 73174030
Access Path: index (AllEqUnique)
Index: PK_ADTPATIENT
resc_io: 2.00 resc_cpu: 16533
ix_sel: 1.8294e-006 ix_sel_with_filters: 1.8294e-006
NL Join: Cost: 841.52 Resp: 841.52 Degree: 1
Cost_io: 839.08 Cost_cpu: 73174030
Resp_io: 839.08 Resp_cpu: 73174030
****** trying bitmap/domain indexes ******
****** finished trying bitmap/domain indexes ******
Best NL cost: 841.52
resc: 841.52 resc_io: 839.08 resc_cpu: 73174030
resp: 841.52 resp_io: 839.08 resp_cpu: 73174030
Join Card: 0.34 = outer (0.34) * inner (546621.00) * sel (1.8294e-006)
Join Card - Rounded: 1 Computed: 0.34
SM Join
Outer table:
resc: 839.52 card 0.34 bytes: 163 deg: 1 resp: 839.52
Inner table: ADTPATIENT Alias: P
resc: 1332.55 card: 546621.00 bytes: 41 deg: 1 resp: 1332.55
using dmeth: 2 #groups: 1
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 1 Row size: 190 Total Rows: 1
Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
Total IO sort cost: 0 Total CPU sort cost: 29976353
Total Temp space used: 0
SORT resource Sort statistics
Sort width: 445 Area size: 390144 Max Area size: 78223360
Degree: 1
Blocks to Sort: 3748 Row size: 56 Total Rows: 546621
Initial runs: 2 Merge passes: 1 IO Cost / pass: 2032
Total IO sort cost: 5780 Total CPU sort cost: 591684408
Total Temp space used: 65872000
SM join: Resc: 7972.81 Resp: 7972.81 [multiMatchCost=0.00]
SM cost: 7972.81
resc: 7972.81 resc_io: 7941.08 resc_cpu: 951056673
resp: 7972.81 resp_io: 7941.08 resp_cpu: 951056673
HA Join
Outer table:
resc: 839.52 card 0.34 bytes: 163 deg: 1 resp: 839.52
Inner table: ADTPATIENT Alias: P
resc: 1332.55 card: 546621.00 bytes: 41 deg: 1 resp: 1332.55
using dmeth: 2 #groups: 1
Cost per ptn: 2.32 #ptns: 1
hash_area: 124 (max=19098) buildfrag: 1 probefrag: 3537 ppasses: 1
Hash join: Resc: 2174.39 Resp: 2174.39 [multiMatchCost=0.00]
HA cost: 2174.39
resc: 2174.39 resc_io: 2161.08 resc_cpu: 399046339
resp: 2174.39 resp_io: 2161.08 resp_cpu: 399046339
Plan cardinality mismatch: best card= 0.33796097408 curr card= 0.33791727990
Best:: JoinMethod: NestedLoop
Cost: 841.52 Degree: 1 Resp: 841.52 Card: 0.34 Bytes: 204
Best so far: Table#: 1 cost: 2.0007 card: 2.0000 bytes: 22
Table#: 3 cost: 338.3037 card: 1048.8517 bytes: 73430
Table#: 2 cost: 341.8088 card: 238.3754 bytes: 19754
Table#: 5 cost: 835.0191 card: 378.6697 bytes: 37900
Table#: 0 cost: 837.5209 card: 0.3381 bytes: 129
Table#: 6 cost: 839.5214 card: 0.3379 bytes: 163
Table#: 4 cost: 841.5220 card: 0.3379 bytes: 204
tage -
Need help in tuning a procedure
DECLARE
CURSOR Cur_sub_rp IS
SELECT A.SUB_ACCOUNT, B.PH_basic_srv,B.PH_Salesman,A.SUB_SSN
FROM STG_SUB_MASTER_MONTH_HISTORY A, STG_PHN_MASTER_MONTH_HISTORY
B
WHERE A.SUB_ACCOUNT = B.PH_ACCOUNT (+)
AND A.MONTH_ID = B.MONTH_ID ;
TYPE t_values_tab IS TABLE OF cur_sub_rp%rowtype ;
values_tab t_values_tab := t_values_tab() ;
BEGIN
OPEN Cur_sub_rp ;
LOOP
FETCH Cur_sub_rp BULK COLLECT INTO Values_tab
LIMIT 1000;
EXIT WHEN Cur_sub_rp%NOTFOUND ;
END LOOP ;
CLOSE Cur_sub_rp;
FORALL i IN VALUES_TAB.first..values_tab.last
INSERT INTO SUB_PHN_1 VALUES VALUES_TAB(i);
commit;
END;
The tables used here has 9 million records each.
The total process takes around 19 minutes.
Need your help in optimizing the process.i have tried using
Create table as SELECT A.SUB_ACCOUNT, B.PH_basic_srv,B.PH_Salesman,A.SUB_SSN
FROM STG_SUB_MASTER_MONTH_HISTORY A, STG_PHN_MASTER_MONTH_HISTORY
B
WHERE A.SUB_ACCOUNT = B.PH_ACCOUNT (+)
AND A.MONTH_ID = B.MONTH_ID (+);But still taking long time(apprx 15 min).
so used this...
help me in tuning the query in either of this.
DECLARE
CURSOR Cur_sub_rp IS
SELECT A.SUB_ACCOUNT, B.PH_basic_srv,B.PH_Salesman,A.SUB_SSN
FROM STG_SUB_MASTER_MONTH_HISTORY A, STG_PHN_MASTER_MONTH_HISTORY
B
WHERE A.SUB_ACCOUNT = B.PH_ACCOUNT (+)
AND A.MONTH_ID = B.MONTH_ID (+);
TYPE t_values_tab IS TABLE OF cur_sub_rp%rowtype ;
values_tab t_values_tab := t_values_tab() ;
BEGIN
OPEN Cur_sub_rp ;
LOOP
FETCH Cur_sub_rp BULK COLLECT INTO Values_tab
LIMIT 1000;
EXIT WHEN Cur_sub_rp%NOTFOUND ;
END LOOP ;
CLOSE Cur_sub_rp;
FORALL i IN VALUES_TAB.first..values_tab.last
INSERT INTO SUB_PHN_1 VALUES VALUES_TAB(i);
commit;
END;Message was edited by:
Vakeel
Message was edited by:
Vakeel -
Need help on tuning materialized view refresh
Hi All,
I am working on materialized view refresh tuning.Initially it was complete refresh and used to take more than 90 mins to complete.
I changed it to fast refresh now it is completing fast. Now i have partitioned the base tables gl_balances and gl_code_combinations of column code_combination_id and created a local index on column code_combination_id then i am trying to partition the materialized on the same column to take advantage of partition change tracking.
Size of gl_balances base tables is 40Gb and all others tables sizes are small. In where clause there all the 4 tables are mapped. If i will create the partition only on code_combination_id will i the materialized will become the candidate for partition change tracking. As i know it will be applicable for PCT. I need expert advice on this.
While doing a fast refresh. the refresh takes less time. when there is a change in gl_balances , gl_code_combinations or gl_periods it completes in 20-30 mins. When there is a change in gl_set_of_books tables. It creates a problem here.DEL query takes more than 48 hours to complete.
CREATE MATERIALIZED VIEW apps.BAL_PART
REFRESH FAST ON DEMAND
ENABLE QUERY REWRITE as
SELECT GL.GL_CODE_COMBINATIONS21.ROWID C1,GL.GL_BALANCES21.ROWID C2, GL.GL_SETS_OF_BOOKS.ROWID C3,
GL.GL_PERIOD.ROWID C4,
"GL"."GL_BALANCES21"."ACTUAL_FLAG" ,
"GL"."GL_BALANCES21"."CURRENCY_CODE" ,
"GL"."GL_BALANCES21"."PERIOD_NUM" ,
"GL"."GL_BALANCES21"."PERIOD_YEAR" ,
"GL"."GL_BALANCES21"."SET_OF_BOOKS_ID" "SOB_ID",
"GL"."GL_CODE_COMBINATIONS21"."CODE_COMBINATION_ID" "CCID",
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT1" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT10" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT11" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT12" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT13" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT14" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT2" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT3" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT4" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT5" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT6" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT7" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT8" ,
"GL"."GL_CODE_COMBINATIONS21"."SEGMENT9" ,
"GL"."GL_PERIODS"."PERIOD_NAME" ,
NVL("GL"."GL_BALANCES21"."BEGIN_BALANCE_CR", 0) Open_Bal_Cr,
NVL("GL"."GL_BALANCES21"."BEGIN_BALANCE_CR", 0) +
NVL("GL"."GL_BALANCES21"."PERIOD_NET_CR", 0) Close_Bal_Cr,
NVL("GL"."GL_BALANCES21"."BEGIN_BALANCE_DR", 0) Open_Bal_Dr,
NVL("GL"."GL_BALANCES21"."BEGIN_BALANCE_DR", 0) +
NVL("GL"."GL_BALANCES21"."PERIOD_NET_DR", 0) Close_Bal_Dr,
NVL("GL"."GL_BALANCES21"."BEGIN_BALANCE_DR", 0) -
NVL("GL"."GL_BALANCES21"."BEGIN_BALANCE_CR", 0) Open_Bal,
NVL("GL"."GL_BALANCES21"."BEGIN_BALANCE_DR", 0) -
NVL("GL"."GL_BALANCES21"."BEGIN_BALANCE_CR", 0) +
NVL("GL"."GL_BALANCES21"."PERIOD_NET_DR", 0) -
NVL("GL"."GL_BALANCES21"."PERIOD_NET_CR", 0) Close_Bal,
NVL("GL"."GL_BALANCES21"."PERIOD_NET_CR", 0) Period_Cr,
NVL("GL"."GL_BALANCES21"."PERIOD_NET_DR", 0) Period_Dr
FROM GL.GL_CODE_COMBINATIONS21,
GL.GL_BALANCES21,
GL.GL_SETS_OF_BOOKS,
GL.GL_PERIODS
WHERE GL.GL_BALANCES21.CODE_COMBINATION_ID =GL.GL_CODE_COMBINATIONS21.CODE_COMBINATION_ID
AND GL.GL_SETS_OF_BOOKS.SET_OF_BOOKS_ID = GL.GL_BALANCES21.SET_OF_BOOKS_ID
AND GL.GL_PERIODS.PERIOD_NUM = GL.GL_BALANCES21.PERIOD_NUM
AND GL.GL_PERIODS.PERIOD_YEAR = GL.GL_BALANCES21.PERIOD_YEAR
AND GL.GL_PERIODS.PERIOD_TYPE = GL.GL_BALANCES21.PERIOD_TYPE
AND GL.GL_PERIODS.PERIOD_NAME = GL.GL_BALANCES21.PERIOD_NAME
AND GL.GL_PERIODS.PERIOD_SET_NAME = GL.GL_SETS_OF_BOOKS.PERIOD_SET_NAME
and gl.GL_CODE_COMBINATIONS21.summary_flag != 'Y'TRACE 1046 del statement
DELETE FROM "APPS"."apps.BAL_PART" SNA$
WHERE "C3" IN (SELECT /*+ NO_MERGE */ * FROM (SELECT
CHARTOROWID("MAS$"."M_ROW$$") RID$ FROM "GL"."MLOG$_GL_SETS_OF_BOOKS"
"MAS$" WHERE "MAS$".SNAPTIME$$ > :B_ST1 ) AS OF SNAPSHOT(:B_SCN) MAS$)
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 17759.00 171782.99 159422121 1267371 2564144739 0
Fetch 0 0.00 0.00 0 0 0 0
total 2 17759.00 171782.99 159422121 1267371 2564144739 0
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 175 (APPS) (recursive depth: 1)
Rows Row Source Operation
0 DELETE apps.BAL_PART (cr=0 pr=0 pw=0 time=0 us)
193128740 NESTED LOOPS (cr=592437 pr=592422 pw=0 time=945244160 us cost=339302 size=168 card=1)
3 SORT UNIQUE (cr=7 pr=0 pw=0 time=15832 us cost=2 size=138 card=1)
24 TABLE ACCESS FULL MLOG$_GL_SETS_OF_BOOKS (cr=7 pr=0 pw=0 time=19 us cost=2 size=138 card=1)
193128740 INDEX RANGE SCAN C3BOOKS (cr=592430 pr=592422 pw=0 time=789499200 us cost=339299 size=3318314250 card=110610475)(object id 2114736)
error during execute of EXPLAIN PLAN statement
ORA-08187: snapshot expression not allowed here
parse error offset: 314
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 159520897 2.12 144415.96
latch: cache buffers chains 134 0.06 0.68
latch: undo global data 33 0.02 0.15
latch: object queue header operation 521 0.02 0.53
log file switch (private strand flush incomplete)
532 0.31 28.26
resmgr:cpu quantum 155 1.40 13.49
resmgr:internal state change 25 0.11 2.21
latch free 10 0.00 0.00
latch: cache buffers lru chain 4 0.00 0.00
rdbms ipc reply 489 0.02 0.54
reliable message 587 0.00 0.56
latch: row cache objects 3 0.00 0.00
********************************************************************************GL_SETS_OF_BOOKS has only 6 rows. I know there is complete refresh as a option which will again take more than 90 mins.
I want to do the fast refresh. Tables rows details below.
SQL> select count(*) from gl.gl_code_combinations21;
COUNT(*)
3075255
SQL> select count(*) from gl.GL_PERIODS;
COUNT(*)
1160
SQL> select count(*) from gl.gl_balances21;
COUNT(*)
477613527
SQL> select count(*) from gl.gl_sets_of_books;
COUNT(*)
6gl_sets_of_books has less rows. Whenever there is a change then it mapped to huge rows hence during materialized view has delete huge number of rows.
select count(*) from apps.BAL_PART group by C3;
C3 is the rowid which is present in create materialized statement.
COUNT(*)
292927011
210215
69330
184406971
Is there any way to improve the plan. As i created a partition on code_combination_id and local index on code_combination_id which will not help in set_of_books_id case. I dont PCT will help here or not. Is it possible to use PCT refresh by equipartitioning only one column in where clause.
Please assist me in improving refresh of materialized view using fast refresh.
Thanks and Regards,
Edited by: user646034 on Feb 23, 2013 11:13 PM
Edited by: user646034 on Feb 23, 2013 11:19 PM
Edited by: user646034 on Feb 23, 2013 11:46 PM
Edited by: user646034 on Feb 25, 2013 11:46 AMHi
The below explain without index and with index.
/* MV_REFRESH (DEL) */ DELETE FROM "APPS"."BAL_PART
" SNA$ WHERE "C3" IN (SELECT /*+ NO_MERGE */ * FROM (SELECT
CHARTOROWID("MAS$"."M_ROW$$") RID$ FROM
"GL"."MLOG$_GL_SETS_OF_BOOKS" "MAS$" WHERE "MAS$".SNAPTIME$$ > :B_ST1
) AS OF SNAPSHOT(:B_SCN) MAS$)
Plan hash value: 2704021294
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time |
| 0 | DELETE STATEMENT | | | | 339K(100)| |
| 1 | DELETE | BAL_PART | | | | |
| 2 | NESTED LOOPS | | 1 | 168 | 339K (1)|999:59:59 |
| 3 | SORT UNIQUE | | 1 | 138 | 2 (0)| 00:02:31 |
| 4 | TABLE ACCESS FULL| MLOG$_GL_SETS_OF_BOOKS | 1 | 138 | 2 (0)| 00:02:31 |
| 5 | INDEX RANGE SCAN | C3BOOKS | 110M| 3164M| 339K (0)|999:59:59 |
If i will not use the C3 index then the query will use the belolw plan, I guess this will also take same time or more time.
| 0 | DELETE STATEMENT | | | | 9743K(100)| |
| 1 | DELETE | BAL_PART | | | |   -
Please help me in tuning sql queries. I am a bit new to this. I have generated an Explain plan(plan table) for a particular sql statement using sql navigator. What do i do with this information exactly in order to tune the statement. It is showing some table access full,merge join cartesian, hash join semi and so on. Can anyone guide me with the general tuning procedure with respect to using the plan table analysis.
Hi,
There is a good metalink note about this one
46234.1 : Interpreting Explain plan
Nicolas. -
Hi All,
I have the following query which seems to be blowing our temp tablespace.
Can anyone help me in tuning this?
The query and explian plan are below.
Thanks for all your help
select trim(b.pnr_reference) || ',"' || to_char(b.booking_date, 'DD-MON-YY') || '","' || trim(p.title) || '","' ||
trim(p.forename) || '","' || trim(p.surname) || '
","' || trim(p.email) || '","' || trim(b.home_phone) || '","' || trim(b.address_line_1) || '","' ||
trim(b.address_line_2) || '","' || trim(b.address_line_3)
|| '","' || trim(b.postcode) || '","' || trim(b.country_code) || '","' || null || '","' || -- frequent flyer number
trim(b.promo_opt_in) || '","' || trim(bsout.flight_number) || '","' || to_char(bsout.departure_date, 'DD-MON-YY') || '","' ||trim(bsret.flight_number) ||
'","' || to_char(bsret.departure_date, 'DD-MON-YY') || ' ","' || pax_cnt.num_adults || '","' || pax_cnt.num_children || '","' || pax_cnt.num_infants || '","' ||fares_by_booking.gross_fare_adult || '","' || fares_by_booking.gross_fare_child || '","' ||fares_by_booking.gross_fare_infant || '","' || fares_by_booking.total_gross_fare || '","' || trim(ps.fare_basis) || '","' ||trim(ps1.fare_basis) || '","' || null || '","' || -- user_id null || '","' || -- ip_address
fares_by_booking.currency || '","' || trim(bsout.dep_airport_code) || '","' ||trim(bsout.dest_airport_code) || '","' ||fares_by_booking.gross_fare_adult*ex.exchange_rate || '","' || null || '","' || -- iata_no
trim(b.other_opt_in) || '","' || c.returned || '","' || c.not_available ||'","' || c.on_request || '","' || c.matched || '"
,"' || trim(c.location_code) || '","' || to_char(c.pickup_date, 'DD-MON-YY') || '","' || to_char(c.return_date, 'DD-MON-YY') || '","' || c.period || '","' ||
trim(cb.book_ref) || '","' || cb.car_num || '","' ||
c.avail_warn_code || '","' || c.avail_err_code || '",
"' || c.res_warn_code || '","' || c.res_err_code |
| '"' from bookings b, car_hire_transactions c, car_hire_bookings cb, pax p, booking_sectors bsout, booking_sectors bsret, pax_sectors ps, pax_sectors ps1,
exchange_rates ex, (select b2.booking_id, sum(decode(p2.pax_type,'A',1,0)) num_adults, sum(decode(p2.pax_type,'C',1,0)) num_children, sum(decode(p2.pax_type,'I',1
,0)) num_infants from pax p2, bookings b2
where b2.booking_id = p2.booking_id and b2.booking_date
between TO_DATE('08-08-2005/00:00', 'DD-MM-YYYY/HH24:MI') and TO_DATE('15-08-2005/00:00', 'DD-MM-YYYY/HH24:MI') group by
b2.booking_id) pax_cnt, (select booking_id, currency, sum(gross_fare_adult) gross_fare_adult,
sum(gross_fare_child) gross_fare_child, sum(gross_fare_infant) gross_fare_infant,sum(total_gross_fare) total_gross_fare from (select b3.booking_id booking_id, ps3.sector_seq,
ps3.currency_code currency, max(decode(p3.pax_type,'A',ps3.gross_fare,0)) gross_fare_adult,
max(decode(p3.pax_type,'C',ps3.gross_fare,0)) gross_fare_child
, max(decode(p3.pax_type,'I',ps3.gross_fare,0
)) gross_fare_infant, sum(ps3.gross_fare) total_gross_fare from pax p3,pax_sectors ps3, bookings b3 where b3.booking_id = p3.booking_id and b3.booking_id = ps3.booking_id and p3.pax_seq = ps3.pax_seq and b3.booking_date between TO_DATE('08-08-2005/00:00', 'DD-MM-Y
YYY/HH24:MI') and TO_DATE('15-08-2005/00:00', 'DD-MM-YYYY/HH24:M
I') group by b3.booking_id, ps3
.currency_code, ps3.sector_seq) fares_by_sector group by booking_id, currency) fares_by_booking where
b.booking_date between TO_DATE('08-08-2005/00:00', 'DD-MM-YYYY/
HH24:MI') and TO_DATE('15-08-2005/00:00', 'DD-MM-YYYY/HH24:MI')
and b.car_hire_id = c.car_hire_id(+) and c.car_hire_id = cb.
car_hire_id(+) and p.booking_id = b.booking_id and p.pax_seq
= 1 and b.booking_id = bsout.booking_id and bsout.sector_seq = 1 and b.booking_id = bsret.booking_id(+) and bsret.sector_seq(+) = 2 and p.booking_id = ps.booking_id and p.pax_seq
= ps.pax_seq and ps.sector_seq = 1 and p.booking_id = ps1.booking_id(+) and p.pax_seq = ps1.pax_seq(+) and ps1.sector_seq(+) = 2 and b.booking_id = pax_cnt.booking_id and b.booking_id = fares_by_booking.booking_id and ex.currency_from = fares_by_booking.currency and ex.currency_to = 'GBP' and ex.date_entered = (select max(ex2.date_entered) from exchange_rates ex2 where currency_from = fares_by_booking.currency and currency_to = 'GBP' and ex2.date_entered < b.booking_date)
Explain plan
11:34:28 sqlpplus> /
Elapsed: 00:00:00.00
Execution Plan
0
SELECT STATEMENT Optimizer=CHOOSE (Cost=16 Card=1 Bytes=973)
1 0
HASH JOIN (OUTER) (Cost=16 Card=1 Bytes=973)
2 1
HASH JOIN (Cost=9 Card=1 Bytes=958)
3 2
NESTED LOOPS (OUTER) (Cost=6 Card=1 Bytes=902)
4 3
NESTED LOOPS (Cost=6 Card=1 Bytes=871)
5 4
NESTED LOOPS (OUTER) (Cost=6 Card=1 Bytes=812)
6 5
NESTED LOOPS (Cost=6 Card=1 Bytes=753)
7 6
NESTED LOOPS (Cost=6 Card=1 Bytes=533)
8 7
NESTED LOOPS (OUTER) (Cost=6 Card=1 Bytes=475)
9 8
NESTED LOOPS (Cost=6 Card=1 Bytes=429)
10 9
NESTED LOOPS (Cost=6 Card=1 Bytes=412)
11 10
VIEW (Cost=6 Card=1 Bytes=75)
12 11
SORT (GROUP BY) (Cost=6 Card=1 Bytes=84)
13 12
VIEW (Cost=6 Card=1 Bytes=84)
14 13
SORT (GROUP BY) (Cost=6 Card=1 Bytes=118)
15 14
FILTER
16 15
TABLE ACCESS (BY INDEX ROWID) OF 'PAX_SECTORS'
17 16
NESTED LOOPS (Cost=4 Card=1 Bytes=118)
18 17
NESTED LOOPS (Cost=4 Card=1 Bytes=60)
19 18
VIEW OF 'index$_join$_017' (Cost=4 Card=1
Bytes=31)
20 19
HASH JOIN
21 20
INDEX (FAST FULL SCAN) OF 'BOO_PK' (UN
IQUE) (Cost=1 Card=1 Bytes=31)
22 20
INDEX (FAST FULL SCAN) OF 'BOO_SHARES_
UID_UK' (UNIQUE) (Cost=1 Card=1 Bytes=31)
23 18
TABLE ACCESS (BY INDEX ROWID) OF 'PAX'
24 23
INDEX (RANGE SCAN) OF 'PAX_PK' (UNIQUE)
25 17
INDEX (RANGE SCAN) OF 'PXS_PAX_FK_I' (NON-UN
IQUE)
26 10
TABLE ACCESS (BY INDEX ROWID) OF 'BOOKINGS'
27 26
INDEX (UNIQUE SCAN) OF 'BOO_PK' (UNIQUE)
28 9
TABLE ACCESS (BY INDEX ROWID) OF 'EXCHANGE_RATES'
29 28
INDEX (UNIQUE SCAN) OF 'EXR_PK' (UNIQUE)
30 29
SORT (AGGREGATE)
31 30
FIRST ROW (Cost=2 Card=284 Bytes=3692)
32 31
INDEX (RANGE SCAN (MIN/MAX)) OF 'EXR_PK' (UNIQUE) (C
ost=2 Card=200)
33 8
TABLE ACCESS (BY INDEX ROWID) OF 'BOOKING_SECTORS'
34 33
INDEX (UNIQUE SCAN) OF 'BKS_PK' (UNIQUE)
35 7
TABLE ACCESS (BY INDEX ROWID) OF 'BOOKING_SECTORS'
36 35
INDEX (UNIQUE SCAN) OF 'BKS_PK' (UNIQUE)
37 6
TABLE ACCESS (BY INDEX ROWID) OF 'PAX'
38 37
INDEX (UNIQUE SCAN) OF 'PAX_PK' (UNIQUE)
39 5
TABLE ACCESS (BY INDEX ROWID) OF 'PAX_SECTORS'
40 39
INDEX (UNIQUE SCAN) OF 'PXS_UK' (UNIQUE)
41 4
TABLE ACCESS (BY INDEX ROWID) OF 'PAX_SECTORS'
42 41
INDEX (UNIQUE SCAN) OF 'PXS_UK' (UNIQUE)
43 3
TABLE ACCESS (BY INDEX ROWID) OF 'CAR_HIRE_TRANSACTIONS'
44 43
INDEX (UNIQUE SCAN) OF 'CHT_PK' (UNIQUE)
45 2
VIEW (Cost=3 Card=1 Bytes=56)
46 45
SORT (GROUP BY) (Cost=3 Card=1 Bytes=47)
47 46
FILTER
48 47
TABLE ACCESS (BY INDEX ROWID) OF 'PAX'
49 48
NESTED LOOPS (Cost=1 Card=1 Bytes=47)
50 49
TABLE ACCESS (BY INDEX ROWID) OF 'BOOKINGS' (Cost=1 Card=1 Bytes
=31)
51 50
INDEX (SKIP SCAN) OF 'BOO_SHARES_UID_UK' (UNIQUE)
52 49
INDEX (RANGE SCAN) OF 'PAX_PK' (UNIQUE)
53 1
TABLE ACCESS (FULL) OF 'CAR_HIRE_BOOKINGS' (Cost=6 Card=7 Bytes=105)Hi Guys,
As requested here is the formatted sql.
We are using pga_aggregate_target which is set to 25165824. I dont know if this is relevant but the sort_area_size is set to 524288.
Thanks
SQL
SELECT trim(b.pnr_reference) || ',"' || to_char(b.booking_date, 'DD-MON-YY')
|| '","' || trim(p.title) || '","' || trim(p.forename) || '","' ||
trim(p.surname) || '","' || trim(p.email) || '","' || trim(b.home_phone)
|| '","' || trim(b.address_line_1) || '","' || trim(b.address_line_2)
|| '","' || trim(b.address_line_3) || '","' || trim(b.postcode) ||
'","' || trim(b.country_code) || '","' || null || '","' || trim(
b.promo_opt_in) || '","' || trim(bsout.flight_number) || '","' ||
to_char(bsout.departure_date, 'DD-MON-YY') || '","' || trim(
bsret.flight_number) || '","' || to_char(bsret.departure_date,
'DD-MON-YY') || '","' || pax_cnt.num_adults || '","' ||
pax_cnt.num_children || '","' || pax_cnt.num_infants || '","' ||
fares_by_booking.gross_fare_adult || '","' ||
fares_by_booking.gross_fare_child || '","' ||
fares_by_booking.gross_fare_infant || '","' ||
fares_by_booking.total_gross_fare || '","' || trim(ps.fare_basis) ||
'","' || trim(ps1.fare_basis) || '","' || null || '","' || null || '","'
|| fares_by_booking.currency || '","' || trim(bsout.dep_airport_code)
|| '","' || trim(bsout.dest_airport_code) || '","' ||
fares_by_booking.gross_fare_adult * ex.exchange_rate || '","' || null
|| '","' || trim(b.other_opt_in) || '","' || c.returned || '","' ||
c.not_available || '","' || c.on_request || '","' || c.matched || '","'
|| trim(c.location_code) || '","' || to_char(c.pickup_date, 'DD-MON-YY'
) || '","' || to_char(c.return_date, 'DD-MON-YY') || '","' || c.period
|| '","' || trim(cb.book_ref) || '","' || cb.car_num || '","' ||
c.avail_warn_code || '","' || c.avail_err_code || '","' ||
c.res_warn_code || '","' || c.res_err_code || '"'
FROM bookings b, car_hire_transactions c, car_hire_bookings cb, pax p,
booking_sectors bsout, booking_sectors bsret, pax_sectors ps,
pax_sectors ps1, exchange_rates ex, (SELECT b2.booking_id, sum(
decode(p2.pax_type, 'A', 1,
0)) num_adults, sum(
decode(p2.pax_type, 'C', 1,
0)) num_children,
sum(decode(p2.pax_type,
'I', 1, 0)) num_infants
FROM pax p2, bookings b2
WHERE b2.booking_id = p2.booking_id
AND b2.booking_date BETWEEN to_date('08-08-2005/00:00',
'DD-MM-YYYY/HH24:MI') AND to_date('15-08-2005/00:00',
'DD-MM-YYYY/HH24:MI')
GROUP BY b2.booking_id) pax_cnt, (SELECT booking_id, currency,
sum(gross_fare_adult)
gross_fare_adult,
sum(gross_fare_child)
gross_fare_child,
sum(gross_fare_infant)
gross_fare_infant,
sum(total_gross_fare)
total_gross_fare
FROM (SELECT b3.booking_id booking_id, ps3.sector_seq,
ps3.currency_code currency, max(decode(p3.pax_type,
'A', ps3.gross_fare, 0)) gross_fare_adult, max(
decode(p3.pax_type, 'C', ps3.gross_fare, 0))
gross_fare_child, max(decode(p3.pax_type, 'I',
ps3.gross_fare, 0)) gross_fare_infant, sum(
ps3.gross_fare) total_gross_fare
FROM pax p3, pax_sectors ps3, bookings b3
WHERE b3.booking_id = p3.booking_id
AND b3.booking_id = ps3.booking_id
AND p3.pax_seq = ps3.pax_seq
AND b3.booking_date BETWEEN to_date(
'08-08-2005/00:00', 'DD-MM-YYYY/HH24:MI') AND
to_date('15-08-2005/00:00', 'DD-MM-YYYY/HH24:MI')
GROUP BY b3.booking_id, ps3.currency_code,
ps3.sector_seq) fares_by_sector
GROUP BY booking_id, currency) fares_by_booking
WHERE b.booking_date BETWEEN to_date('08-08-2005/00:00',
'DD-MM-YYYY/HH24:MI') AND to_date('15-08-2005/00:00',
'DD-MM-YYYY/HH24:MI')
AND b.car_hire_id = c.car_hire_id (+)
AND c.car_hire_id = cb.car_hire_id (+)
AND p.booking_id = b.booking_id
AND p.pax_seq = 1
AND b.booking_id = bsout.booking_id
AND bsout.sector_seq = 1
AND b.booking_id = bsret.booking_id (+)
AND bsret.sector_seq (+) = 2
AND p.booking_id = ps.booking_id
AND p.pax_seq = ps.pax_seq
AND ps.sector_seq = 1
AND p.booking_id = ps1.booking_id (+)
AND p.pax_seq = ps1.pax_seq (+)
AND ps1.sector_seq (+) = 2
AND b.booking_id = pax_cnt.booking_id
AND b.booking_id = fares_by_booking.booking_id
AND ex.currency_from = fares_by_booking.currency
AND ex.currency_to = 'GBP'
AND ex.date_entered = (SELECT max(ex2.date_entered)
FROM exchange_rates ex2
WHERE currency_from = fares_by_booking.currency
AND currency_to = 'GBP'
AND ex2.date_entered < b.booking_date)
explain_plan
Execution Steps:
Step # Step Name
41 SELECT STATEMENT
40 FILTER
36 NESTED LOOPS [OUTER]
33 NESTED LOOPS
30 HASH JOIN [OUTER]
28 NESTED LOOPS [OUTER]
25 HASH JOIN
23 HASH JOIN [OUTER]
21 HASH JOIN
15 HASH JOIN
5 HASH JOIN
3 HASH JOIN
1 CAM_OWNER.PAX_SECTORS TABLE ACCESS [FULL]
2 CAM_OWNER.PAX TABLE ACCESS [FULL]
4 CAM_OWNER.BOOKINGS TABLE ACCESS [FULL]
14 . VIEW
13 SORT [GROUP BY]
12 . VIEW
11 SORT [GROUP BY]
10 HASH JOIN
8 HASH JOIN
6 CAM_OWNER.BOOKINGS TABLE ACCESS [FULL]
7 CAM_OWNER.PAX_SECTORS TABLE ACCESS [FULL]
9 CAM_OWNER.PAX TABLE ACCESS [FULL]
20 . VIEW
19 SORT [GROUP BY]
18 HASH JOIN
16 CAM_OWNER.BOOKINGS TABLE ACCESS [FULL]
17 CAM_OWNER.PAX TABLE ACCESS [FULL]
22 CAM_OWNER.PAX_SECTORS TABLE ACCESS [FULL]
24 CAM_OWNER.EXCHANGE_RATES TABLE ACCESS [FULL]
27 CAM_OWNER.CAR_HIRE_TRANSACTIONS TABLE ACCESS [BY INDEX ROWID]
26 CAM_OWNER.CHT_PK INDEX [UNIQUE SCAN]
29 CAM_OWNER.CAR_HIRE_BOOKINGS TABLE ACCESS [FULL]
32 CAM_OWNER.BOOKING_SECTORS TABLE ACCESS [BY INDEX ROWID]
31 CAM_OWNER.BKS_PK INDEX [UNIQUE SCAN]
35 CAM_OWNER.BOOKING_SECTORS TABLE ACCESS [BY INDEX ROWID]
34 CAM_OWNER.BKS_PK INDEX [UNIQUE SCAN]
39 SORT [AGGREGATE]
38 FIRST ROW
37 CAM_OWNER.EXR_PK INDEX [RANGE SCAN (MIN/MAX)] -
Need help th tuning query or re write the query--
Hi,
Need help to tune the below query or rewrite th query for reducing the execution time Please find the query and explain plan.
QUERY
explain plan FOR SELECT consumer_key,product_key,days_in_product,20100201 period_key FROM
(SELECT consumer_key,
product_key,
days_in_product,
row_number() over ( Partition BY consumer_key order by Days_in_product DESC) row_num
FROM
(SELECT consumer_key,
product_key,
SUM(no_ofdays) days_in_product
FROM
(SELECT pcv.consumer_key,
pcv.product_key,
pcv.product_consumer_valid_from,
pcv.product_consumer_valid_to,
DECODE (SIGN(20100201000000-product_consumer_valid_from),1,20100201000000,product_consumer_valid_from) period_start,
DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959) period_end,
CASE
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) BETWEEN 20100201000000 AND 20100228235959
AND activation_date > to_Date(product_consumer_valid_to,'YYYYMMDDHH24MISS')
THEN 0
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) BETWEEN 20100201000000 AND 20100228235959
AND activation_date BETWEEN to_Date(product_consumer_valid_from,'YYYYMMDDHH24MISS') AND to_Date(product_consumer_valid_to,'YYYYMMDDHH24MISS')
THEN
--to_char(activation_date,'MON-YYYY')='PERIOD_ACTIVE' and activation_date >= to_Date(product_consumer_valid_from,'YYYYMMDDHH24MISS') then
(to_date(DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959),'YYYYMMDDHH24MISS') - to_date(TO_CHAR(activation_date,'YYYYMMDDHH24MISS'),'YYYYMMDDHH24MISS') )
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) < 20100201000000
THEN (to_date(DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959),'YYYYMMDDHH24MISS') - to_Date(DECODE (SIGN(20100201000000-product_consumer_valid_from),1,20100201000000,product_consumer_valid_from),'YYYYMMDDHH24MISS') )
WHEN to_number(TO_CHAR(cd.activation_date,'YYYYMMDDHH24MISS')) > 20100228235959
THEN 0
ELSE
--unusual situation
(to_date(DECODE (SIGN(20100228235959-product_consumer_valid_to),1,product_consumer_valid_to,20100228235959),'YYYYMMDDHH24MISS') - to_Date(DECODE (SIGN(20100201000000-product_consumer_valid_from),1,20100201000000,product_consumer_valid_from),'YYYYMMDDHH24MISS') )
END No_ofDays
FROM cimtran.product_consumer_validity pcv,
consumer_dimension cd
WHERE pcv.consumer_key =cd.consumer_key
AND product_consumer_valid_to >= 20100201000000
AND product_consumer_valid_from <= 20100228235959
--and product_consumer_valid_from > '20090801000000'
ORDER BY consumer_key,
product_key,
product_consumer_valid_from
) a
GROUP BY consumer_key,
product_key
ORDER BY consumer_key,
product_key
) WHERE row_num=1 ;EXPLAIN PLAN
"PLAN_TABLE_OUTPUT"
"Plan hash value: 3823907703"
"| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |"
"| 0 | SELECT STATEMENT | | 4665K| 231M| | 133K (1)| 00:31:08 |"
"|* 1 | VIEW | | 4665K| 231M| | 133K (1)| 00:31:08 |"
"|* 2 | WINDOW SORT PUSHED RANK| | 4665K| 173M| 232M| 133K (1)| 00:31:08 |"
"| 3 | VIEW | | 4665K| 173M| | 104K (1)| 00:24:18 |"
"| 4 | SORT GROUP BY | | 4665K| 182M| 729M| 104K (1)| 00:24:18 |"
"|* 5 | HASH JOIN | | 13M| 533M| 65M| 44241 (1)| 00:10:20 |"
"| 6 | TABLE ACCESS FULL | CONSUMER_DIMENSION | 2657K| 35M| | 4337 (1)| 00:01:01 |"
"|* 7 | TABLE ACCESS FULL | PRODUCT_CONSUMER_VALIDITY | 13M| 351M| | 15340 (2)| 00:03:35 |"
"Predicate Information (identified by operation id):"
" 1 - filter(""ROW_NUM""=1)"
" 2 - filter(ROW_NUMBER() OVER ( PARTITION BY ""CONSUMER_KEY"" ORDER BY "
" INTERNAL_FUNCTION(""DAYS_IN_PRODUCT"") DESC )<=1)"
" 5 - access(""PCV"".""CONSUMER_KEY""=""CD"".""CONSUMER_KEY"")"
" 7 - filter(""PRODUCT_CONSUMER_VALID_FROM""<=20100228235959 AND "
" ""PRODUCT_CONSUMER_VALID_TO"">=20100201000000)"I doubt that this query can be tuned without using indexes. There is a lot of unnecessary work specified in your query, like unnecessary intermediate sorting and selecting unused columns. The cost based optimizer recognized it and skips some of that unnecessary work, it seems. For clarity's sake, I would rewrite your query like below. Note that the query is untested:
select consumer_key
, max(product_key) keep (dense_rank last order by days_in_product) product_key
, max(days_in_product) days_in_product
, 20100201 period_key
from ( select pcv.consumer_key
, pcv.product_key
, sum
( case
when to_number(to_char(cd.activation_date,'yyyymmddhh24miss')) between 20100201000000 and 20100228235959
then
case
when cd.activation_date > to_date(pcv.product_consumer_valid_to,'yyyymmddhh24miss')
then
0
when cd.activation_date between to_date(pcv.product_consumer_valid_from,'yyyymmddhh24miss') and to_date(product_consumer_valid_to,'yyyymmddhh24miss')
then
to_date(to_char(pcv.product_consumer_valid_to),'yyyymmddhh24miss'))
- to_date(to_char(activation_date,'yyyymmddhh24miss'),'yyyymmddhh24miss')
end
when to_number(to_char(cd.activation_date,'yyyymmddhh24miss')) < 20100201000000
then
to_date(to_char(pcv.product_consumer_valid_to),'yyyymmddhh24miss'))
- to_date(to_char(pcv.product_consumer_valid_from),'yyyymmddhh24miss'))
when to_number(to_char(cd.activation_date,'yyyymmddhh24miss')) > 20100228235959
then
0
end
) days_in_product
from cimtran.product_consumer_validity pcv
, consumer_dimension cd
where pcv.consumer_key = cd.consumer_key
and product_consumer_valid_to >= 20100201000000
and product_consumer_valid_from <= 20100228235959
group by consumer_key
, product_key
group by consumer_keyRegards,
Rob. -
Hi,
I have the following query/report that takes hours to complete. Application version is 11.5.9 and database is on 9.2.0.6
{code}
SELECT c.inventory_location_id,
c.segment1
|| '.'
|| c.segment2
|| '.'
|| c.segment3
|| '.'
|| c.segment4 loc,
b.lot_number lot, -1 * b.primary_quantity lot_qty
FROM mtl_material_transactions a,
mtl_transaction_lot_numbers b,
mtl_item_locations c
WHERE a.transaction_id = b.transaction_id
AND a.locator_id = c.inventory_location_id
AND a.trx_source_line_id = :b1
ORDER BY 1
{code}
Explain Plan shows the following
{code}
SELECT STATEMENT CHOOSECost: 694
9 SORT ORDER BY Cost: 694 Bytes: 96 Cardinality: 2
8 TABLE ACCESS BY INDEX ROWID INV.MTL_TRANSACTION_LOT_NUMBERS Cost: 4 Bytes: 17 Cardinality: 1
7 NESTED LOOPS Cost: 693 Bytes: 96 Cardinality: 2
5 NESTED LOOPS Cost: 687 Bytes: 62 Cardinality: 2
2 TABLE ACCESS BY INDEX ROWID INV.MTL_MATERIAL_TRANSACTIONS Cost: 683 Bytes: 26 Cardinality: 2
1 INDEX FULL SCAN INV.NFPC_LOCATOR_ID_N1 Cost: 27 Cardinality: 2,579,440
4 TABLE ACCESS BY INDEX ROWID INV.MTL_ITEM_LOCATIONS Cost: 3 Bytes: 18 Cardinality: 1
3 INDEX RANGE SCAN INV.MTL_ITEM_LOCATIONS_U1 Cost: 2 Cardinality: 1
6 INDEX RANGE SCAN INV.MTL_TRANSACTION_LOT_NUMBERS_N1 Cost: 3 Cardinality: 1
{code}
Please let me know what other information I need to upload for any help.
Thanks
AJHi,
How many rows you have in MMT table?
Have you gathered the stats of the INV schema recently?
Did you test with some optimizer hints such as /*+ ordered */ or even /*+ rule */ ?
Regards,
Bashar -
Need Help in tuning of the query
Hi all,
Can any body help me how we can rewrite this query in
optimized way.
SELECT A.C1 AS COLUMN_1, B.C2 AS COLUMN_2
FROM A,B
WHERE A.C1 IN (
SELECT COLUMN_1 FROM(
(SELECT A.C1 AS COLUMN_1,
COUNT(C1) AS COUNT,
RANK() OVER (ORDER BY COUNT(C1) DESC) AS RANK
FROM A, B, C
WHERE A.C1 = B.C3
AND B.C2 = C.C1
AND <other conditions>
GROUP BY A.C1)
WHERE RANK <= 10)
AND A.C1 = B.C3
AND <other conditions>
ORDER BY A.C1
I am using <other conditions> are same in outer query and inner query also.
Thanks in Advance,Hi,
Yes exactly I am looking TOP-10 results the query is like this
SELECT A.C1 AS COLUMN_1, B.C2 AS COLUMN_2
FROM A,B
WHERE B.C2 IN (
SELECT COLUMN_1 FROM(
(SELECT B.C2 AS COLUMN_1,
COUNT(A.C1) AS COUNT,
RANK() OVER (ORDER BY COUNT(C1) DESC) AS RANK
FROM A, B, C
WHERE A.C1 = B.C3
AND B.C2 = C.C1
AND <other conditions>
GROUP BY B.C2)
WHERE RANK <= 10)
AND A.C1 = B.C3
AND <other conditions>
ORDER BY B.C2
Thanks -
Pls see this attached query. This is hitting a table which has around 110 mil recs. And this takes around 60 min to execute. IS there any way to tune it better? I am assuming that because this uses the ' With tmp as' clauses, it might be using the Indexes.
Can anyone suggest some tuning tips?
Satish
WITH all_edbc_pending_edg
AS (SELECT
a.day_sk,
a.case_num,
a.edg_num,
a.edg_trace_id,
a.application_dt,
a.current_elig_ind,
a.payment_begin_dt payment_beg_dt
FROM fct_eligibility_2 a,
dim_edg_activity_type b
WHERE a.current_elig_ind IN ('P','S','A')
and mod(case_num,2)=0
AND b.eff_end_dt IS NULL
AND b.activity_type_cd IN ('IN','RE','IR','PR','OG')
AND a.activity_type_sk=b.activity_type_sk
, Pick_Latest_Prior_Med as
SELECT t3.case_num,
t3.edg_num,
t3.current_elig_ind,
t3.application_dt,
t3.day_sk,
t3.payment_beg_dt,
t3.edg_trace_id
FROM (SELECT t2.*,
Row_number()
OVER(PARTITION BY t2.case_num,t2.edg_num, t2.application_dt ORDER BY t2.day_sk DESC, t2.payment_beg_dt DESC, t2.edg_trace_id DESC) AS rn
FROM all_edbc_pending_edg t2) t3
WHERE t3.rn = 1
Select
case_num,
edg_num,
application_dt,
payment_beg_dt,
edg_trace_id,
current_elig_ind
FROM
SELECT t1.case_num,
t1.edg_num,
t1.application_dt,
t1.payment_beg_dt,
t1.edg_trace_id,
t1.current_elig_ind
FROM (SELECT t.*,
Row_number()
OVER(PARTITION BY t.case_num,t.edg_num ORDER BY t.day_sk DESC, t.payment_beg_dt DESC, t.edg_trace_id DESC) AS rn
FROM Pick_Latest_Prior_Med t) t1
WHERE t1.rn = 1
) p
WHERE
current_elig_ind IN ('P','S')Check this link and post what is required as mentioned in the link.
SQL and PL/SQL FAQ
>
I am assuming that because this uses the ' With tmp as' clauses, it might be using the Indexes.
>
You don't need to assume. You can find out what's exactly happening if you follow the steps described in the above mentioned link.
Regards
Raj -
Hi,
I have a query in my proj where the same table is looked up twice in the same query.
Can anybody suggest in improving the performance of this query?
select * from table1 a1 where (a1.column1, a1.column2, a1.column3, a1.column4, a1.column5, a1.column6, a1.column7, a1.column8, a1.column9,
a1.column10) in ( select a2.column1, a2.column2, a2.column3, a2.column4, a2.column5, a2.column6, a2.column7, a2.column8, a2.column9,
a2.column10 from table1 a2 where column20 = '<condn>')
The table1 used here is same in outer query as well as the sub query. this is a example of what we use here, and the table1 contains 30 million rows. Though, creating index with 10 columns can be a option, we already have a unique index with 11 columns(which includes 10 from this query) and will that be helpful in anyway? or the same existing index can be forced?
Thanks a lot for ur timeDepending on the selectivity of column20 I am not sure Index is the best way to go. It might perform better with two full scans and a hash-join.
Anyway, I do prefer the syntax:
select /*+ leading(a2) */ a1.*
from table1 a1, table1 a2
where a2.column20 = '<condn>'
and a1.column1 = a2.column1
and a1.column2 = a2.column2
and a1.column3 = a2.column3
and a1.column4 = a2.column4
and a1.column5 = a2.column5
and a1.column6 = a2.column6
and a1.column7 = a2.column7
and a1.column8 = a2.column8
and a1.column9 = a2.column9
and a1.column10 = a2.column10;I've added a leading hint to tell oracle that the start table is a2. Might be useless.
Ensure your stats are up to date. You might need histograms here if your column20 is skewed.
Hope this helps,
François
Edited by: Francois Berger on Oct 24, 2008 1:47 AM -
Need help further tuning view source for outer join
I have been working on tuning views for use in Discoverer for some time, and I have greatly improved upon what was there, but it is still not where I need it to be. There are 2 views the users join together in Discoverer - one for contract lines, and one for contract flexfields. Run as a 1 to 1 join on contract number, performance is great. However, as soon as I have an outer join on flexfields, the performance is awful. We are talking a difference of under a minute to hours and hours. I have to be able to perform an outer join because there can be contracts without flexfields. Can anyone suggest an alternative method to get the data or further tuning? I will paste both the contract lines and contract flexfields source - I have tuned the flexfields but have done nothing to date with the lines.
CREATE OR REPLACE VIEW XXDBD_CONTRACT_FLEXFIELDS AS
SELECT core.contract_id, core.service_id, core.contract_number, core.service_line, core.service, core.product_line, core.equipment, core.UL_Certificate_And_End_Date, core.MAF, core.Termination_Penalty_Percentage, core.multi_year, core.multi_year_effective_dates, core.terms_multi_year, core.SerLineRenPricingMethod, core.ren_line_change, core.zone, core.add_invoice_display, core.add_subgrouping, re.diebold_price, attr.coverage_hours, attr.reaction_times, attr.resolution_times, attr.repair_times, tr.performance_requirement, attr.penalty, attr.penalty_amount, attr.penalty_bonus, attr.mon_break_start, attr.mon_break_end, attr.tues_break_start, attr.tues_break_end, attr.wed_break_start, attr.wed_break_end, attr.thu_break_start, attr.thu_break_end, attr.fri_break_start, attr.fri_break_end, attr.sat_break_start, attr.sat_break_end, attr.sun_break_start, attr.sun_break_end, attr.split_covering, attr.cash_handling
FROM (SELECT aa.ID Contract_id,
aa.contract_number,
dd.id Service_ID ,
dd.cle_id dd_cle_id,
dd.line_number service_line,
xxdbd_Disco_Service_Contract.GetServNameInv
(dd.id) Service,
dd.line_number ||'.'||ee.line_number Product_Line,
xxdbd_Disco_Service_Contract.GetEqpNoInvoice(ee.id)
Equipment,
DECODE(dd.attribute_category,'Service Contracts',
NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_50_CHARS', dd.attribute1),dd.attribute1),'') UL_Certificate_And_End_Date,
dd.attribute2 MAF,
DECODE(dd.attribute_category,'Service Contracts',NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_NUMERIC', dd.attribute3),dd.attribute3),'') Termination_Penalty_Percentage,
DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_MULTIYEAR', dd.attribute5),dd.attribute5),
'N','No Multi-Year',
'Y','Multi-Year, Years not Known',
'Y1','Multi-Year for 1 Year',
'Y2','Multi-Year for 2 Year',
'Y3','Multi-Year for 3 Year',
'Y4','Multi-Year for 4 Year',
'Y5','Multi-Year for 4 Year',dd.attribute5),'')Multi_Year,
dd.attribute4 Multi_Year_Effective_Dates,
DECODE(dd.attribute_category,'Service Contracts', NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_450_CHARS', dd.attribute9),dd.attribute9),'') Terms_Multi_Year,
DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_RENEWAL_PRICING', dd.attribute6),dd.attribute6),
'MP', 'DBD Markup Percent',
'CP', 'DBD Contract Price',
'AI', 'DBD Amount Increase',
'AD', 'DBD Amount Decrease',
'TA', 'DBD Target Amount',
'FR', 'DBD Flat Rate',dd.attribute6),'') SerLineRenPricingMethod,
DECODE(dd.attribute_category,'Service Contracts', NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_NUMERIC', dd.attribute7),dd.attribute7),'') Ren_Line_Change,
DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_ZONE', dd.attribute8),dd.attribute8),
'DNA1','DNA Zone 1',
'DNA2','DNA Zone 2',
'DNA3','DNA Zone 3',
'BRAZIL1','Brazil Zone 1 (50 KM)',
'BRAZIL2','Brazil Zone 2 (80 KM)',
'BRAZIL3','Brazil Zone 3 (200 KM)',dd.attribute8),'')Zone,
DECODE(dd.attribute11, 'N','None','SC','Sub Component', 'SN', 'Serial Number', 'SNSC', 'Serial Number and Sub-Component') Add_Invoice_Display,
DECODE(dd.attribute10, 'SI','Service Item', 'CP','Covered Product', 'PC','Product Category') Add_SubGrouping,
dd.attribute12 Diebold_Price,
ee.id ee_id,
ee.cle_id ee_cle_id
FROM okc_k_headers_b aa,
okc_k_lines_b dd,
okc_k_lines_b ee
-- xxdbd_temp_flex_contract tfc
WHERE aa.id = dd.DNZ_CHR_ID
AND dd.CLE_ID IS NULL
AND dd.id = ee.cle_id
AND ee.DNZ_CHR_ID = aa.id
AND ee.LSE_ID =9
AND dd.LSE_ID =1
-- and aa.contract_number = 'NL0000014'
-- and aa.contract_number in (select contract_number from xxdbd_flex_contract)
-- AND tfc.contract_number = aa.contract_number
) core,
(SELECT h.contract_number,
DECODE(l.attribute_category,
'Coverage Break', xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,2)),
'Business Process',xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,1)),
'Coverage Template Header',xxdbd_get_sib_cont_id(l.cle_id),
'Transaction Type', xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,2)),null) ee_id,
DECODE(l.attribute_category, 'Business Process', l.attribute1) Coverage_Hours,
DECODE(l.attribute_category, 'Business Process', l.attribute2) Reaction_Times,
DECODE(l.attribute_category, 'Business Process', l.attribute3) Resolution_Times,
DECODE(l.attribute_category, 'Business Process', l.attribute4) Repair_Times,
DECODE(l.attribute_category, 'Business Process', DECODE(l.attribute5,
'RA', 'REACTION'
, 'RS', 'RESOLUTION'
, 'RR', 'REACTION & RESOLUTION'
, 'NR', 'NO REQUIREMENT',
l.attribute5)) Performance_Requirement,
DECODE(l.attribute_category, 'Coverage Template Header', l.attribute1) Penalty,
DECODE(l.attribute_category, 'Coverage Template Header', l.attribute2) Penalty_Amount,
DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute2) Mon_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute3) Tues_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute4) Tues_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute5) Wed_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute6) Wed_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute7) Thu_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute8) Thu_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute9) Fri_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute10) Fri_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute11) Sat_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute12) Sat_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute13) Sun_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute14) Sun_Break_End,
DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,
DECODE(l.attribute_category, 'Transaction Type', l.attribute2) Cash_Handling
from okc_k_lines_b l , okc_k_headers_b h--, xxdbd_temp_flex_contract tfc
where l.attribute_category in ('Coverage Break', 'Business Process', 'Coverage Template Header','Transaction Type')
and h.id = l.dnz_chr_id
-- and h.contract_number in (select contract_number from xxdbd_flex_contract)
-- and tfc.contract_number = h.contract_number
) attr
where core.ee_id = attr.ee_id (+)
and core.contract_number = attr.contract_number (+);
create or replace view xxdbd_contract_lines as
select aa.id Contract_id,
bb.id Service_id,
aa.CONTRACT_NUMBER,
F1.USER_NAME Created_By,
F2.USER_NAME LastUpdated_By,
bb.LINE_NUMBER Service_Line_No,
bb.LINE_NUMBER ||'.'|| cc.LINE_NUMBER Product_Line_No,
xxdbd_Disco_Service_Contract.GetServNameInv(bb.id) Service,
xxdbd_Disco_Service_Contract.GetServDescInv(bb.id) Service_Desc,
xxdbd_Disco_Service_Contract.GetServicePrice(bb.id) Service_Price,
bb.PRICE_UNIT Service_List_Price,
bb.CURRENCY_CODE,
aa.SCS_CODE Contract_Type,
bb.STS_CODE Service_Status,
bb.TRN_CODE Term_Code,
bb.START_DATE Service_start,
bb.END_DATE Service_end,
TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(Null, bb.id, 'OKX_BILLTO' )) SERVICE_BillToSite,
xxdbd_Disco_Service_Contract.GetLocAccount(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(Null, bb.id, 'OKX_BILLTO' ))) Bill_Account,
xxdbd_Disco_Service_Contract.GetLocation(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_BILLTO' ))) Service_BillTo,
TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' )) SERVICE_ShipToSite ,
xxdbd_Disco_Service_Contract.GetLocation(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' ))) Service_Ship_To,
xxdbd_Disco_Service_Contract.GetLocAccount(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' ))) Ship_Account,
bb.DATE_RENEWED,
bb.DATE_TERMINATED,
cc.START_DATE Eqp_Start,
cc.END_DATE Eqp_End,
xxdbd_Disco_Service_Contract.GetEqpNoInvoice(cc.id) Eqp_No,
xxdbd_Disco_Service_Contract.GetEqpDescInvoice(cc.ID) Eqp_Desc,
xxdbd_Disco_Service_Contract.GetEqpQuantityInvoice(cc.id) Eqp_Quan,
xxdbd_Disco_Service_Contract.GetEqpSerialNoInvoice(cc.id) Eqp_Serial,
xxdbd_Disco_Service_Contract.GetCustomerCt(aa.id, bb.id) Cust_Contact,
DD.ORGANIZATION_ID,
dd.INSTALL_ADDRESS,
dd.INSTALL_DATE,
dd.INSTALL_SITE_ID INSTALL_SITE_USE_ID,
dd.PARTY_SITE_NAME INSTALL_SITE_NAME,
dd.PARTY_SITE_NUMBER INSTALL_SITE_NUMBER
,cii.inventory_item_id
,cii.inv_master_organization_id
,aa.authoring_org_id
,cc.id equipment_id
,TO_NUMBER(replace(bb.attribute12,',','')) annual_contract_amt
,ou.name operating_unit
,ou.organization_id operating_unit_id
,substr(xxdbd_ra_utility.Get_BusinessProcess(cc.cle_id),1,100) business_process
,cii.instance_id
,cii.instance_number
from okc_k_headers_b aa
,okc_k_lines_b bb
,okc_k_lines_b cc
,fnd_user f1
,fnd_user f2
,csi_item_instances cii
,okc_k_items items
,hr_all_organization_units ou
,xxdbd_oks_install_info_v dd
where aa.id = bb.dnz_chr_id
and bb.cle_id is null
and cc.cle_id = bb.id
and cc.dnz_chr_id = aa.id
and f1.user_id = bb.created_by
and f2.user_id = bb.last_updated_by
and cc.lse_id in (9,25,18,40)
and dd.line_id (+) = cc.id
and items.cle_id = cc.id
and cii.instance_id = items.object1_id1
and aa.authoring_org_id = ou.organization_id (+);
Here are the explain plans from TOAD:
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE 6 49124
NESTED LOOPS OUTER 6 80 K 49124
VIEW 6 80 K 49112
HASH JOIN 6 1 K 49112
HASH JOIN 17 K 2 M 20214
TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 175 K 37
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 17 K 1 M 20162
INDEX SKIP SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 39 17085
TABLE ACCESS FULL OKC.OKC_K_LINES_B 502 K 34 M 27803
VIEW PUSHED PREDICATE 1 107 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 42 3 K 216
NESTED LOOPS 50 5 K 219
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 33 3
INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE 245 63309
NESTED LOOPS 245 291 K 63309
NESTED LOOPS OUTER 245 286 K 63064
NESTED LOOPS 245 80 K 62574
HASH JOIN 245 74 K 61839
HASH JOIN 245 71 K 61756
HASH JOIN OUTER 245 68 K 61673
HASH JOIN 245 60 K 61664
HASH JOIN 205 K 32 M 28046
TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 244 K 37
TABLE ACCESS FULL OKC.OKC_K_LINES_B 205 K 23 M 27803
TABLE ACCESS FULL OKC.OKC_K_LINES_B 2 M 168 M 27803
TABLE ACCESS FULL HR.HR_ALL_ORGANIZATION_UNITS 2 K 64 K 8
TABLE ACCESS FULL APPLSYS.FND_USER 13 K 172 K 81
TABLE ACCESS FULL APPLSYS.FND_USER 13 K 172 K 81
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
VIEW APPS.XXDBD_OKS_INSTALL_INFO_V 1 861 2
UNION-ALL PARTITION
NESTED LOOPS 1 167 9
NESTED LOOPS 1 108 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTY_SITES 1 23 1
INDEX UNIQUE SCAN AR.HZ_PARTY_SITES_U1 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 144 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 161 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTIES 1 76 1
INDEX UNIQUE SCAN AR.HZ_PARTIES_U1 1
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 21 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
And here is the SQL to join:
select * from xxdbd_contract_lines l, xxdbd_contract_flexfields f
where f.service_id (+) = l.service_id
and f.contract_number (+) = l.contract_number
and l.contract_number = 'NL0000014'
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE 1 49221
HASH JOIN OUTER 1 38 K 49221
VIEW APPS.XXDBD_CONTRACT_LINES 1 19 K 96
NESTED LOOPS OUTER 1 1 K 96
NESTED LOOPS 1 358 94
NESTED LOOPS 1 345 93
NESTED LOOPS 1 332 92
NESTED LOOPS 1 311 91
NESTED LOOPS 1 285 88
NESTED LOOPS 448 72 K 88
NESTED LOOPS OUTER 1 78 4
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 46 3
INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
TABLE ACCESS BY INDEX ROWID HR.HR_ALL_ORGANIZATION_UNITS 1 32 1
INDEX UNIQUE SCAN HR.HR_ORGANIZATION_UNITS_PK 1
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 378 32 K 84
INDEX RANGE SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 378 16
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 119
INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 21 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID APPLSYS.FND_USER 1 13 1
INDEX UNIQUE SCAN APPLSYS.FND_USER_U1 1
TABLE ACCESS BY INDEX ROWID APPLSYS.FND_USER 1 13 1
INDEX UNIQUE SCAN APPLSYS.FND_USER_U1 1
VIEW APPS.XXDBD_OKS_INSTALL_INFO_V 1 861 2
UNION-ALL PARTITION
NESTED LOOPS 1 167 9
NESTED LOOPS 1 108 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTY_SITES 1 23 1
INDEX UNIQUE SCAN AR.HZ_PARTY_SITES_U1 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 144 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 161 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTIES 1 76 1
INDEX UNIQUE SCAN AR.HZ_PARTIES_U1 1
VIEW APPS.XXDBD_CONTRACT_FLEXFIELDS 6 112 K 49124
NESTED LOOPS OUTER 6 80 K 49124
VIEW 6 80 K 49112
HASH JOIN 6 1 K 49112
HASH JOIN 17 K 2 M 20214
TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 175 K 37
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 17 K 1 M 20162
INDEX SKIP SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 39 17085
TABLE ACCESS FULL OKC.OKC_K_LINES_B 502 K 34 M 27803
VIEW PUSHED PREDICATE 1 107 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 42 3 K 216
NESTED LOOPS 50 5 K 219
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 33 3
INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,Uh oh, the dreaded entity attibute value, or generic, data model.
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:10678084117056
I am afraid slow performance is a built in feature of this database design, not much you can do in queries.
You could possibly create the views as materialized views and query those instead.
Quote from the linked article
But, how does it perform? Miserably, terribly, horribly. A simple "select
first_name, last_name from person" query is transformed into a 3-table join with
aggregates and all. Further, if the attributes are "NULLABLE" - that is, there
might not be a row in OBJECT_ATTRIBUTES for some attributes, you may have to
outer join instead of just joining which in some cases can remove more optimal
query plans from consideration.
Writing queries might look pretty straightforward, but it's impossible to do in
a performant fashion. -
HELP ME TUNING MY DB STRUCTURE
Hi
I need a suggestion. Well, in my db I have types STUDENT, TEACHER and THESIS(final exam). Teacher and student are subtypes of PERSON, and I have a table USERS of PERSON, and a table EXAMS of THESIS.
A teacher is a tutor for many students, so each teacher has its nested table of ref THESIS which represent it. Each student has got to the maximum one THESIS assigned, so he as an attribute THESIS of type THESIS.
Each THESIS is managed by a teacher and to the maximum a student.
So, both STUDENT AND TEACHER point to THESIS. But if I want to retrieve information about the other person (for example, I select a student and I want to know who is his tutor), which is the best way?
1. add to type THESIS two attributes of type ref student and ref teacher, creating a circular dependence
2. create a function that takes in input an object of type THESIS and returns the relative teacher or student
I hope you could help me..thanks in advanceif i understand it correctly you had already a query (the select statments) but when executing that query it does takes long and the performance is not good right? correct me if i am wrong.
-
Help fine-tuning new signatures
Could anyone please help. I recently installed a PIX 5520 with AIP-SSM-10. I can manage the sensor just fine and am using "configuring Cisco IPS using CLI 6.0" as a reference. I recently downloaded new signatures as sig1 on my sensor. when I enable the sensors and put them in non-blocking mode after an hour they are blocking half of my users to the INternet. How do I fine-tune the 50K new signatures? Are there any really good examples and references you might know about?
You should be able to quickly locate which signatures are causing problems by using either the ASDM or IPS Express Manager. If you dont have either of these programs go to Cisco's site and download them.
You can use the event viewer in either program and look for signatues which have actions of blocking or dropping packets from your internal users. You should then be able to tune only the signatures causing problems.
Also, when you download the new signatues, look at the txt document that is released with it. It should list any new signatures as well as any changes to old signatures. -
can anyone give some help on the best setup for my system including over clocking
here is the details of my system and thanx in advance
processor intel pentium 4
code name northwood
voltage 1.536v
specification intel cpu 3.06ghz
core speed 3006mhz
multiplier x15.0
fsb 200.0mhz
bus speed 800.0mhz
L1 date 8 kbytes
L1 trace 12kbytes
Level 2 512kbytes
L2 cacha
location on chip
size 512kbytes
associativity 8-way
line size 64bytes
ratio full
frequency 3006 mhz
bus width 256 bits
prefetch lodge yes
motherboard
micro-star inc.
model ms-6728 100
chip intel i865p/pe/g/i848p rev a2
southbridge intel 82801eb [1ch5]
AGP
revision 3.0
aperture size 256mb
data transer rate 8x
side band addressing
memory
1024 mbytes
channels dual
performance mode enabled
modules info dane-elec DDR-SDRAM PC3200-X2
frequency 133.3mhz
fsb dram 3:4
cas#latency 2.0 clocks
ras#to cas# delay 3 clocks
ras# percharge 2 clocks
cycle time [tras] 5 clocksThere is no one overclockring to rule them all. Try here instead: https://forum-en.msi.com/index.php?boardid=27&sid=
Maybe you are looking for
-
Possible to view Keynote files / presentations as read only ?
Keynote has been a wonderful study tool: I can tap the screen on my iPad2 or iPhone4, and the next bit of information appears (using the "builds" effects to make new info appear, eg: answers to questions). It's just like flash cards, but on an Apple
-
Submit Form Via Webmail Is Not Creating Email In Drafts Folder
Bottom Line Up Front: PDF's Submit via Email (Webmail) is not creating the email in the Webmail account. What I am using: ============= * Adobe Acrobat Pro XI; however, I have a lot of users using Adobe Reader. * Yahoo! email What I am trying to do:
-
Smartform Error "No defined value'
Hi , I am getting an error message in smartform 'Amount field has no defined value'. I have declared the amount field in global data & it has default value as '0' & i am computing its value in one of the nodes. When i try to print this field value at
-
Time Machine Online Backup????
Is there a way to use the time machine backup function to backup to an online service?? If not...what are the best practices/options when your Time Machine backup disk is full?? Can you add additional backup disks, or are there better ways to deal wi
-
Can someone please show me a code example of how to use RS_EXTERNAL_SELSCREEN_STATUS function. I want to delete "Create delivery in background" pushbutton from report vl10h.