ITrip tuning help?
Found my old iPod and want to set up my old iTrip and can't figure it out. Help?
create a smart playlist, excluding itrip stations
Similar Messages
-
Hi,
I need some help on tuning this sql. We run a third party application and I have to ask thrid party for any changes. I have pasted the session statistice from the run for this sql.
SELECT DECODE( RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,
' ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' '),
RPAD(NVL(:zipout1,' '),4,' ')||RPAD(NVL(:zipin1,' '),3,' '),
'0001', RPAD(NVL(:zipout2,' '),4,'
')||RPAD(SUBSTR(NVL(:zipin2,' '),0,1),3,' '), '0002',
RPAD(NVL(:zipout3,' '),7,' '), '0003',
RPAD('ZZ999',7,' '), '0004' ) AS CHECKER
FROM NWKPCDREC
WHERE NWKPCDNETWORKID = :netid
AND NWKPCDSORTPOINT1TYPE != 'XXXXXXXX'
AND ( (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,' ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') =
RPAD(NVL(:zipout4,' '),4,' ')||RPAD(NVL(:zipin3,' '),3,' '))
OR (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,'
')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') =
RPAD(NVL(:zipout5,' '),4,' ')||RPAD(SUBSTR(NVL(:zipin4,' '),0,
1),3,' ')) OR (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,'
')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') =
RPAD(NVL(:zipout6,' '),7,' ')) OR
(RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,'
')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') = RPAD('ZZ999',7,
' ')) ) ORDER BY CHECKER
Session Statistics 09 October 2007 22:44:56 GMT+00:00
Report Target : PRD1 (Database)
Session Statistics
(Chart form was tabular, see data table below)
SID Name Value Class
37 write clones created in foreground 0 Cache
37 write clones created in background 0 Cache
37 user rollbacks 16 User
37 user commits 8674 User
37 user calls 302838 User
37 transaction tables consistent reads - undo records applied 0 Debug
37 transaction tables consistent read rollbacks 0 Debug
37 transaction rollbacks 9 Debug
37 transaction lock foreground wait time 0 Debug
37 transaction lock foreground requests 0 Debug
37 transaction lock background gets 0 Debug
37 transaction lock background get time 0 Debug
37 total file opens 12 Cache
37 table scans (short tables) 8062 SQL
37 table scans (rowid ranges) 0 SQL
37 table scans (long tables) 89 SQL
37 table scans (direct read) 0 SQL
37 table scans (cache partitions) 2 SQL
37 table scan rows gotten 487042810 SQL
37 table scan blocks gotten 7327924 SQL
37 table fetch continued row 17 SQL
37 table fetch by rowid 26130550 SQL
37 switch current to new buffer 6400 Cache
37 summed dirty queue length 0 Cache
37 sorts (rows) 138607 SQL
37 sorts (memory) 13418 SQL
37 sorts (disk) 0 SQL
37 session uga memory max 5176776 User
37 session uga memory 81136 User
37 session stored procedure space 0 User
37 session pga memory max 5559884 User
37 session pga memory 5559884 User
37 session logical reads 115050107 User
37 session cursor cache hits 0 SQL
37 session cursor cache count 0 SQL
37 session connect time 1191953042 User
37 serializable aborts 0 User
37 rows fetched via callback 1295545 SQL
37 rollbacks only - consistent read gets 0 Debug
37 rollback changes - undo records applied 114 Debug
37 remote instance undo header writes 0 Global Cache
37 remote instance undo block writes 0 Global Cache
37 redo writes 0 Redo
37 redo writer latching time 0 Redo
37 redo write time 0 Redo
37 redo wastage 0 Redo
37 redo synch writes 8683 Cache
37 redo synch time 722 Cache
37 redo size 25463692 Redo
37 redo ordering marks 0 Redo
37 redo log switch interrupts 0 Redo
37 redo log space wait time 0 Redo
37 redo log space requests 1 Redo
37 redo entries 81930 Redo
37 redo buffer allocation retries 1 Redo
37 redo blocks written 0 Redo
37 recursive cpu usage 101 User
37 recursive calls 84413 User
37 recovery blocks read 0 Cache
37 recovery array reads 0 Cache
37 recovery array read time 0 Cache
37 queries parallelized 0 Parallel Server
37 process last non-idle time 1191953042 Debug
37 prefetched blocks aged out before use 0 Cache
37 prefetched blocks 1436767 Cache
37 pinned buffers inspected 89 Cache
37 physical writes non checkpoint 3507 Cache
37 physical writes direct (lob) 0 Cache
37 physical writes direct 3507 Cache
37 physical writes 3507 Cache
37 physical reads direct (lob) 0 Cache
37 physical reads direct 2499 Cache
37 physical reads 1591668 Cache
37 parse time elapsed 336 SQL
37 parse time cpu 315 SQL
37 parse count (total) 28651 SQL
37 parse count (hard) 1178 SQL
37 opens requiring cache replacement 0 Cache
37 opens of replaced files 0 Cache
37 opened cursors current 51 User
37 opened cursors cumulative 28651 User
37 no work - consistent read gets 59086317 Debug
37 no buffer to keep pinned count 0 Other
37 next scns gotten without going to DLM 0 Parallel Server
37 native hash arithmetic fail 0 SQL
37 native hash arithmetic execute 0 SQL
37 messages sent 9730 Debug
37 messages received 0 Debug
37 logons current 1 User
37 logons cumulative 1 User
37 leaf node splits 111 Debug
37 kcmgss waited for batching 0 Parallel Server
37 kcmgss read scn without going to DLM 0 Parallel Server
37 kcmccs called get current scn 0 Parallel Server
37 instance recovery database freeze count 0 Parallel Server
37 index fast full scans (rowid ranges) 0 SQL
37 index fast full scans (full) 210 SQL
37 index fast full scans (direct read) 0 SQL
37 immediate (CURRENT) block cleanout applications 4064 Debug
37 immediate (CR) block cleanout applications 83 Debug
37 hot buffers moved to head of LRU 20004 Cache
37 global lock sync gets 0 Parallel Server
37 global lock sync converts 0 Parallel Server
37 global lock releases 0 Parallel Server
37 global lock get time 0 Parallel Server
37 global lock convert time 0 Parallel Server
37 global lock async gets 0 Parallel Server
37 global lock async converts 0 Parallel Server
37 global cache read buffer lock timeouts 0 Global Cache
37 global cache read buffer blocks served 0 Global Cache
37 global cache read buffer blocks received 0 Global Cache
37 global cache read buffer block timeouts 0 Global Cache
37 global cache read buffer block send time 0 Global Cache
37 global cache read buffer block receive time 0 Global Cache
37 global cache read buffer block build time 0 Global Cache
37 global cache prepare failures 0 Global Cache
37 global cache gets 0 Global Cache
37 global cache get time 0 Global Cache
37 global cache freelist waits 0 Global Cache
37 global cache defers 0 Global Cache
37 global cache cr timeouts 0 Global Cache
37 global cache cr requests blocked 0 Global Cache
37 global cache cr blocks served 0 Global Cache
37 global cache cr blocks received 0 Global Cache
37 global cache cr block send time 0 Global Cache
37 global cache cr block receive time 0 Global Cache
37 global cache cr block flush time 0 Global Cache
37 global cache cr block build time 0 Global Cache
37 global cache converts 0 Global Cache
37 global cache convert timeouts 0 Global Cache
37 global cache convert time 0 Global Cache
37 global cache blocks corrupt 0 Global Cache
37 free buffer requested 1597281 Cache
37 free buffer inspected 659 Cache
37 execute count 128826 SQL
37 exchange deadlocks 1 Cache
37 enqueue waits 0 Enqueue
37 enqueue timeouts 0 Enqueue
37 enqueue requests 23715 Enqueue
37 enqueue releases 23715 Enqueue
37 enqueue deadlocks 0 Enqueue
37 enqueue conversions 0 Enqueue
37 dirty buffers inspected 437 Cache
37 deferred (CURRENT) block cleanout applications 21937 Debug
37 db block gets 230801 Cache
37 db block changes 160407 Cache
37 data blocks consistent reads - undo records applied 460 Debug
37 cursor authentications 488 Debug
37 current blocks converted for CR 0 Cache
37 consistent gets 114819307 Cache
37 consistent changes 460 Cache
37 commit cleanouts successfully completed 37201 Cache
37 commit cleanouts 37210 Cache
37 commit cleanout failures: write disabled 0 Cache
37 commit cleanout failures: hot backup in progress 0 Cache
37 commit cleanout failures: cannot pin 0 Cache
37 commit cleanout failures: callback failure 3 Cache
37 commit cleanout failures: buffer being written 0 Cache
37 commit cleanout failures: block lost 6 Cache
37 cold recycle reads 0 Cache
37 cluster key scans 17 SQL
37 cluster key scan block gets 36 SQL
37 cleanouts only - consistent read gets 83 Debug
37 cleanouts and rollbacks - consistent read gets 0 Debug
37 change write time 108 Cache
37 calls to kcmgrs 0 Debug
37 calls to kcmgcs 391 Debug
37 calls to kcmgas 8816 Debug
37 calls to get snapshot scn: kcmgss 171453 Parallel Server
37 bytes sent via SQL*Net to dblink 0 User
37 bytes sent via SQL*Net to client 25363874 User
37 bytes received via SQL*Net from dblink 0 User
37 bytes received via SQL*Net from client 29829542 User
37 buffer is pinned count 540816 Other
37 buffer is not pinned count 86108905 Other
37 branch node splits 6 Debug
37 background timeouts 0 Debug
37 background checkpoints started 0 Cache
37 background checkpoints completed 0 Cache
37 Unnecesary process cleanup for SCN batching 0 Parallel Server
37 SQL*Net roundtrips to/from dblink 0 User
37 SQL*Net roundtrips to/from client 302837 User
37 Parallel operations not downgraded 0 Parallel Server
37 Parallel operations downgraded to serial 0 Parallel Server
37 Parallel operations downgraded 75 to 99 pct 0 Parallel Server
37 Parallel operations downgraded 50 to 75 pct 0 Parallel Server
37 Parallel operations downgraded 25 to 50 pct 0 Parallel Server
37 Parallel operations downgraded 1 to 25 pct 0 Parallel Server
37 PX remote messages sent 0 Parallel Server
37 PX remote messages recv'd 0 Parallel Server
37 PX local messages sent 0 Parallel Server
37 PX local messages recv'd 0 Parallel Server
37 OS Voluntary context switches 0 OS
37 OS User time used 0 OS
37 OS System time used 0 OS
37 OS Swaps 0 OS
37 OS Socket messages sent 0 OS
37 OS Socket messages received 0 OS
37 OS Signals received 0 OS
37 OS Page reclaims 0 OS
37 OS Page faults 0 OS
37 OS Maximum resident set size 0 OS
37 OS Involuntary context switches 0 OS
37 OS Integral unshared stack size 0 OS
37 OS Integral unshared data size 0 OS
37 OS Integral shared text size 0 OS
37 OS Block output operations 0 OS
37 OS Block input operations 0 OS
37 DML statements parallelized 0 Parallel Server
37 DFO trees parallelized 0 Parallel Server
37 DDL statements parallelized 0 Parallel Server
37 DBWR undo block writes 0 Cache
37 DBWR transaction table writes 0 Cache
37 DBWR summed scan depth 0 Cache
37 DBWR revisited being-written buffer 0 Cache
37 DBWR make free requests 0 Cache
37 DBWR lru scans 0 Cache
37 DBWR free buffers found 0 Cache
37 DBWR cross instance writes 0 Global Cache
37 DBWR checkpoints 0 Cache
37 DBWR checkpoint buffers written 0 Cache
37 DBWR buffers scanned 0 Cache
37 Commit SCN cached 0 Debug
37 Cached Commit SCN referenced 1 Debug
37 CR blocks created 203 Cache
37 CPU used when call started 280528 Debug
37 CPU used by this session 280528 User
Regards
Raj
--------------------------------------------------------------------------------Thank you everybody for helping me out while tuning the query. I have managed to bring down the run time from 60 minutes to 12 minutes.
I am posting the exisitng query, existing database objects ddl and the new query and new ddl to share my learning. This is my first use of forum, senior members, please letme know if I shouldn't have put all this here.
/pre original code
SELECT decode(rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
a.nwkpcdinwdpostcode, ' '), 3, ' '), rpad(nvl(:zipout1, ' '), 4, ' ')
|| rpad(nvl(:zipin1, ' '), 3, ' '), '0001', rpad(nvl(:zipout2, ' '), 4,
' ') || rpad(substr(nvl(:zipin2, ' '), 0, 1), 3, ' '), '0002',
rpad(nvl(:zipout3, ' '), 7, ' '), '0003', rpad('ZZ999', 7, ' '), '0004')
AS checker, a.nwkpcdbarcode1to7 nwkpcdbarcode1to7,
a.nwkpcdbarcode15 nwkpcdbarcode15,
a.nwkpcdbarcodeseqkey nwkpcdbarcodeseqkey,
a.nwkpcdsortpoint1code nwkpcdsortpoint1code,
a.nwkpcdsortpoint1type nwkpcdsortpoint1type,
a.nwkpcdsortpoint1name nwkpcdsortpoint1name,
a.nwkpcdsortpoint1extra nwkpcdsortpoint1extra,
a.nwkpcdsortpoint2type nwkpcdsortpoint2type,
a.nwkpcdsortpoint2name nwkpcdsortpoint2name,
a.nwkpcdsortpoint3type nwkpcdsortpoint3type,
a.nwkpcdsortpoint3name nwkpcdsortpoint3name,
a.nwkpcdsortpoint4type nwkpcdsortpoint4type,
a.nwkpcdsortpoint4name nwkpcdsortpoint4name,
b.nwkprfnetworksequence nwkprfnetworksequence,
b.nwkprfnetworkid nwkprfnetworkid, b.nwkprfnetworkname nwkprfnetworkname,
b.nwkprfminweight / 100 AS nwkprfminweight, b.nwkprfmaxweight / 100 AS
nwkprfmaxweight, b.nwkprfminlengthgirth nwkprfminlengthgirth,
b.nwkprfmaxlengthgirth nwkprfmaxlengthgirth,
b.nwkprfminlength nwkprfminlength, b.nwkprfmaxlength nwkprfmaxlength,
b.nwkprfparceltypecode nwkprfparceltypecode,
b.nwkprfparceltypename nwkprfparceltypename
FROM wh1.nwkpcdrec a, wh1.nwkprefrec b
WHERE a.nwkpcdnetworkid = b.nwkprfnetworkid
AND a.nwkpcdsortpoint1type != 'XXXXXXXX'
AND (rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad(nvl(:zipout4, ' '), 4, ' '
) || rpad(nvl(:zipin3, ' '), 3, ' ')
OR rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad(nvl(:zipout5, ' '), 4, ' '
) || rpad(substr(nvl(:zipin4, ' '), 0, 1), 3, ' ')
OR rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad(nvl(:zipout6, ' '), 7, ' '
OR rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad('ZZ999', 7, ' '))
AND :weight1 >= b.nwkprfminweight
AND :weight2 <= b.nwkprfmaxweight
AND b.nwkprfminlengthgirth <= 60
AND b.nwkprfmaxlengthgirth >= 60
AND b.nwkprfminlength <= 15
AND b.nwkprfmaxlength >= 15
ORDER BY b.nwkprfnetworkid, checker
CREATE TABLE "WH1"."NWKPCDREC" ("NWKPCDFILECODE" VARCHAR2(2),
"NWKPCDRECORDTYPE" VARCHAR2(4), "NWKPCDNETWORKID" VARCHAR2(2),
"NWKPCDOUTWDPOSTCODE" VARCHAR2(4), "NWKPCDINWDPOSTCODE"
VARCHAR2(3), "NWKPCDSORTPOINT1CODE" VARCHAR2(2),
"NWKPCDSORTPOINT1TYPE" VARCHAR2(8), "NWKPCDSORTPOINT1NAME"
VARCHAR2(16), "NWKPCDSORTPOINT1EXTRA" VARCHAR2(16),
"NWKPCDSORTPOINT2TYPE" VARCHAR2(8), "NWKPCDSORTPOINT2NAME"
VARCHAR2(8), "NWKPCDSORTPOINT3TYPE" VARCHAR2(8),
"NWKPCDSORTPOINT3NAME" VARCHAR2(8), "NWKPCDSORTPOINT4TYPE"
VARCHAR2(8), "NWKPCDSORTPOINT4NAME" VARCHAR2(8), "NWKPCDPPI"
VARCHAR2(8), "NWKPCDBARCODE1TO7" VARCHAR2(7),
"NWKPCDBARCODE15" VARCHAR2(1), "NWKPCDBARCODESEQKEY"
VARCHAR2(7), "NWKPCDFILLER1" VARCHAR2(7), "NWKPCDFILLER2"
VARCHAR2(30),
CONSTRAINT "UK_NWKPCDREC" UNIQUE("NWKPCDNETWORKID",
"NWKPCDOUTWDPOSTCODE", "NWKPCDINWDPOSTCODE")
USING INDEX
TABLESPACE "WH1_INDEX"
STORAGE ( INITIAL 64K NEXT 0K MINEXTENTS 1 MAXEXTENTS
2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
PCTFREE 10 INITRANS 2 MAXTRANS 255)
TABLESPACE "WH1_DATA_LARGE" PCTFREE 10 PCTUSED 40 INITRANS 1
MAXTRANS 255
STORAGE ( INITIAL 4096K NEXT 4096K MINEXTENTS 1 MAXEXTENTS
2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
NOLOGGING
pre original script/
/pre modified script
CREATE TABLE "WH1"."NWKPCEREC_OLD" ("NWKPCDFILECODE" VARCHAR2(2),
"NWKPCDRECORDTYPE" VARCHAR2(4), "NWKPCDNETWORKID" VARCHAR2(2),
"NWKPCDOUTWDPOSTCODE" VARCHAR2(4), "NWKPCDINWDPOSTCODE"
VARCHAR2(3), "NWKPCDSORTPOINT1CODE" VARCHAR2(2),
"NWKPCDSORTPOINT1TYPE" VARCHAR2(8), "NWKPCDSORTPOINT1NAME"
VARCHAR2(16), "NWKPCDSORTPOINT1EXTRA" VARCHAR2(16),
"NWKPCDSORTPOINT2TYPE" VARCHAR2(8), "NWKPCDSORTPOINT2NAME"
VARCHAR2(8), "NWKPCDSORTPOINT3TYPE" VARCHAR2(8),
"NWKPCDSORTPOINT3NAME" VARCHAR2(8), "NWKPCDSORTPOINT4TYPE"
VARCHAR2(8), "NWKPCDSORTPOINT4NAME" VARCHAR2(8), "NWKPCDPPI"
VARCHAR2(8), "NWKPCDBARCODE1TO7" VARCHAR2(7),
"NWKPCDBARCODE15" VARCHAR2(1), "NWKPCDBARCODESEQKEY"
VARCHAR2(7), "NWKPCDFILLER1" VARCHAR2(7), "NWKPCDFILLER2"
VARCHAR2(30))
TABLESPACE "WH1_DATA_LARGE" PCTFREE 10 PCTUSED 40 INITRANS 1
MAXTRANS 255
STORAGE ( INITIAL 4096K NEXT 4096K MINEXTENTS 1 MAXEXTENTS
2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
NOLOGGING
insert into wh1.nwkpcdrec_old select * from wh1.nwkpcdrec;
drop table wh1.nwkpcdrec;
CREATE TABLE "WH1"."NWKPCDREC" ("NWKPCDFILECODE" VARCHAR2(2),
"NWKPCDRECORDTYPE" VARCHAR2(4), "NWKPCDNETWORKID" VARCHAR2(2),
"NWKPCDOUTINWDPOSTCODE" VARCHAR2(7) NOT NULL,
"NWKPCDOUTWDPOSTCODE" VARCHAR2(4), "NWKPCDINWDPOSTCODE"
VARCHAR2(3), "NWKPCDSORTPOINT1CODE" VARCHAR2(2),
"NWKPCDSORTPOINT1TYPE" VARCHAR2(8), "NWKPCDSORTPOINT1NAME"
VARCHAR2(16), "NWKPCDSORTPOINT1EXTRA" VARCHAR2(16),
"NWKPCDSORTPOINT2TYPE" VARCHAR2(8), "NWKPCDSORTPOINT2NAME"
VARCHAR2(8), "NWKPCDSORTPOINT3TYPE" VARCHAR2(8),
"NWKPCDSORTPOINT3NAME" VARCHAR2(8), "NWKPCDSORTPOINT4TYPE"
VARCHAR2(8), "NWKPCDSORTPOINT4NAME" VARCHAR2(8), "NWKPCDPPI"
VARCHAR2(8), "NWKPCDBARCODE1TO7" VARCHAR2(7),
"NWKPCDBARCODE15" VARCHAR2(1), "NWKPCDBARCODESEQKEY"
VARCHAR2(7), "NWKPCDFILLER1" VARCHAR2(7), "NWKPCDFILLER2"
VARCHAR2(30))
TABLESPACE "WH1_DATA_LARGE" PCTFREE 10 PCTUSED 40 INITRANS 1
MAXTRANS 255
STORAGE ( INITIAL 4096K NEXT 4096K MINEXTENTS 1 MAXEXTENTS
2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
NOLOGGING
INSERT INTO WH1.NWKPCDREC SELECT
NWKPCDFILECODE,
NWKPCDRECORDTYPE,
NWKPCDNETWORKID,
rpad(nvl(nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(nwkpcdinwdpostcode, ' '), 3, ' '),
nwkpcdoutwdpostcode,
nwkpcdinwdpostcode,
NWKPCDSORTPOINT1CODE,
NWKPCDSORTPOINT1TYPE,
NWKPCDSORTPOINT1NAME,
NWKPCDSORTPOINT1EXTRA,
NWKPCDSORTPOINT2TYPE,
NWKPCDSORTPOINT2NAME,
NWKPCDSORTPOINT3TYPE,
NWKPCDSORTPOINT3NAME,
NWKPCDSORTPOINT4TYPE,
NWKPCDSORTPOINT4NAME,
NWKPCDPPI,
NWKPCDBARCODE1TO7,
NWKPCDBARCODE15,
NWKPCDBARCODESEQKEY,
NWKPCDFILLER1,
NWKPCDFILLER2
FROM WH1.NWKPCDREC_OLD;
CREATE UNIQUE INDEX "WH1"."UK_NWKPCDREC"
ON "WH1"."NWKPCDREC" ("NWKPCDNETWORKID",
"NWKPCDOUTINWDPOSTCODE")
TABLESPACE "WH1_INDEX" PCTFREE 10 INITRANS 2 MAXTRANS
255
STORAGE ( INITIAL 8192K NEXT 8192K MINEXTENTS 1 MAXEXTENTS
2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
LOGGING
begin
dbms_stats.gather_table_stats(ownname=> 'WH1', tabname=> 'NWKPCDREC', partname=> NULL);
end;
begin
dbms_stats.gather_index_stats(ownname=> 'WH1', indname=> 'UK_NWKPCDREC', partname=> NULL);
end;
SELECT decode(a.nwkpcdoutinwdpostcode, rpad(nvl(:zipout1, ' '), 4, ' ') ||
rpad(nvl(:zipin1, ' '), 3, ' '), '0001', rpad(nvl(:zipout2, ' '), 4, ' '
) || rpad(substr(nvl(:zipin2, ' '), 0, 1), 3, ' '), '0002', rpad(
nvl(:zipout3, ' '), 7, ' '), '0003', rpad('ZZ999', 7, ' '), '0004') AS
checker, a.nwkpcdbarcode1to7 nwkpcdbarcode1to7,
a.nwkpcdbarcode15 nwkpcdbarcode15,
a.nwkpcdbarcodeseqkey nwkpcdbarcodeseqkey,
a.nwkpcdsortpoint1code nwkpcdsortpoint1code,
a.nwkpcdsortpoint1type nwkpcdsortpoint1type,
a.nwkpcdsortpoint1name nwkpcdsortpoint1name,
a.nwkpcdsortpoint1extra nwkpcdsortpoint1extra,
a.nwkpcdsortpoint2type nwkpcdsortpoint2type,
a.nwkpcdsortpoint2name nwkpcdsortpoint2name,
a.nwkpcdsortpoint3type nwkpcdsortpoint3type,
a.nwkpcdsortpoint3name nwkpcdsortpoint3name,
a.nwkpcdsortpoint4type nwkpcdsortpoint4type,
a.nwkpcdsortpoint4name nwkpcdsortpoint4name,
b.nwkprfnetworksequence nwkprfnetworksequence,
b.nwkprfnetworkid nwkprfnetworkid, b.nwkprfnetworkname nwkprfnetworkname,
b.nwkprfminweight / 100 AS nwkprfminweight, b.nwkprfmaxweight / 100 AS
nwkprfmaxweight, b.nwkprfminlengthgirth nwkprfminlengthgirth,
b.nwkprfmaxlengthgirth nwkprfmaxlengthgirth,
b.nwkprfminlength nwkprfminlength, b.nwkprfmaxlength nwkprfmaxlength,
b.nwkprfparceltypecode nwkprfparceltypecode,
b.nwkprfparceltypename nwkprfparceltypename
FROM wh1.nwkpcdrec a, wh1.nwkprefrec b
WHERE a.nwkpcdnetworkid = b.nwkprfnetworkid
AND a.nwkpcdoutinwdpostcode IN (rpad(nvl(:zipout4, ' '), 4, ' ') ||
rpad(nvl(:zipin3, ' '), 3, ' '), rpad(nvl(:zipout5, ' '), 4, ' ')
|| rpad(substr(nvl(:zipin4, ' '), 0, 1), 3, ' '), rpad(nvl(:zipout6,
' '), 7, ' '), rpad('ZZ999', 7, ' '))
AND a.nwkpcdsortpoint1type != 'XXXXXXXX'
AND :weight1 >= b.nwkprfminweight
AND :weight2 <= b.nwkprfmaxweight
AND b.nwkprfminlengthgirth <= 60
AND b.nwkprfmaxlengthgirth >= 60
AND b.nwkprfminlength <= 15
AND b.nwkprfmaxlength >= 15
ORDER BY b.nwkprfnetworkid, checker
pre modified script/ -
Hello,
I need you help, tuning this query; it is showing in the top activity and it takes the highest % of total elapsed time, CPU TIME, and it is executed 3170 times in the one hour AWR snapshot
select * from ( select this_.TOP_ID as topology1_8_0_, this_.DEV_O as device2_8_0_, this_.DEV_PRODC as device3_8_0_,
this_.DEV_SNUMBER as device4_8_0_, this_.DISP_NAME as displayN5_8_0_,
this_.IP_ADR as IP_ADR8_0_, this_.LAST_SC as lastatte7_8_0_,
this_.LAST_SA as LAST_SA8_0_, this_.SUBS_EX_ID as subscriber9_8_0_
from NETFREE this_ where (this_.LAST_SA<=:1 or this_.LAST_SA is null)
and (this_.LAST_SC<=:2 or this_.LAST_SC is null)
order by this_.LAST_SC asc ) where rownum <= :3This is the definition of the query:
(database 11.2.0.1)
SQL> SET LONG 10000
SQL> SELECT dbms_metadata.get_ddl('TABLE','NETFREE','HR_USER') FROm DUAL;
DBMS_METADATA.GET_DDL('TABLE','NETFREE','HR_USER')
CREATE TABLE "HR_USER"."NETFREE"
( "TOP_ID" VARCHAR2(255 CHAR) NOT NULL ENABLE,
"DEV_O" VARCHAR2(6 CHAR),
"DEV_PRODC" VARCHAR2(255 CHAR),
"DEV_SNUMBER" VARCHAR2(255 CHAR),
"DISP_NAME" VARCHAR2(255 CHAR),
"IP_ADR" VARCHAR2(255 CHAR) NOT NULL ENABLE,
"LAST_SC" TIMESTAMP (6),
"LAST_SA" TIMESTAMP (6),
"SUBS_EX_ID" VARCHAR2(255 CHAR) NOT NULL ENABLE,
DBMS_METADATA.GET_DDL('TABLE','NETFREE','HR_USER')
PRIMARY KEY ("TOP_ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DE
FAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "HOM_TBS" ENABLE
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DE
FAULT CELL_FLASH_CACHE DEFAULT)
DBMS_METADATA.GET_DDL('TABLE','NETFREE','HR_USER')
TABLESPACE "HOM_TBS"
SQL>
SQL> SELECT NUM_ROWS , LAST_ANALYZED from DBA_TABLES WHERE TABLE_NAME='NETFREE';
NUM_ROWS LAST_ANAL
200000 24-AUG-11
SQL>
SQL> SELECT * FROM TABLE(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3516113232
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
|
PLAN_TABLE_OUTPUT
| 0 | SELECT STATEMENT | | 500 | 393K| 999 (2)| 00:00:1
2 |
|* 1 | COUNT STOPKEY | | | | |
|
| 2 | VIEW | | 500 | 393K| 999 (2)| 00:00:1
2 |
|* 3 | SORT ORDER BY STOPKEY| | 500 | 59000 | 999 (2)| 00:00:1
2 |
PLAN_TABLE_OUTPUT
|* 4 | TABLE ACCESS FULL | NETFREE | 500 | 59000 | 998 (1)| 00:00:1
2 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter(ROWNUM<=TO_NUMBER(:3))
3 - filter(ROWNUM<=TO_NUMBER(:3))
4 - filter(("THIS_"."LAST_SA"<=TO_TIMESTAMP(:1) OR "THIS_"."LAST_SA"
IS NULL) AND ("THIS_"."LAST_SC"<=TO_TIMESTAMP(:2) OR
"THIS_"."LAST_SC" IS NULL))
20 rows selected.
SQL>This is the TKPROF output; after doing alter session set sql_trace=true and run the query;
-bash-3.2$ cat a.txt
TKPROF: Release 11.2.0.1.0 - Development on Fri Aug 26 10:33:19 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Trace file: db01_ora_24672.trc
Sort options: prsela exeela fchela
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 2 0.01 0.01 0 0 0 0
Execute 3 0.00 0.00 0 0 0 0
Fetch 70 0.15 0.15 0 3653 0 1002
total 75 0.17 0.17 0 3653 0 1002
Misses in library cache during parse: 2
Misses in library cache during execute: 1
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 6 0.00 0.00 0 0 0 0
Execute 13 0.00 0.00 0 0 0 0
Fetch 13 0.00 0.00 0 27 0 4
total 32 0.00 0.00 0 27 0 4
Misses in library cache during parse: 6
Misses in library cache during execute: 5
3 user SQL statements in session.
14 internal SQL statements in session.
17 SQL statements in session.
Trace file: db01_ora_24672.trc
Trace file compatibility: 11.1.0.7
Sort options: prsela exeela fchela
1 session in tracefile.
3 user SQL statements in trace file.
14 internal SQL statements in trace file.
17 SQL statements in trace file.
9 unique SQL statements in trace file.
418 lines in trace file.
123 elapsed seconds in trace file.
-bash-3.2$ -
I have a select statement that I am repeating 12 times with the only difference between them all being the date range that is grabbed. Essentially, I am grabbing the last 12 months of information from the same table here is a copy of one of the sections:
(select
a.account_id as account_id,
a.company_id as company_id,
a.account_number as acct_number,
to_char(a.trx_date, 'YYYY/MM') as month,
sum(a.amount_due_original) as amount
from
crystal.financial_vw a
where
a.cust_since_dt is not null
and a.cust_end_dt is null
and a.trx_date > add_months(sysdate, -13)
and a.trx_date <= add_months(sysdate, -12)
group by
a.account_id,
a.company_id,
a.account_number,
to_char(a.trx_date, 'YYYY/MM')) b
I am now looking to do some tuning on this and was wondering if anyone has any suggestions. My initial thought was to use cursors or some sort of in memory storage to temporarily process the information into a pipe-delimited flat file."Don't need:
to_char(a.trx_date, 'YYYY/MM')"
Are you sure?
"Change to (just to make it easier to read):
a.trx_date between add_months(sysdate, -13)
and a.trx_date <= add_months(sysdate, -12)"
What? That's not even valid syntax is it? Besides the fact that the BETWEEN operator is inclusive (i.e. > add_months(sysdate, -13) is not the same as between add_months(sysdate, -13) ...).
"And be sure you have an index on:
cust_since_dt, cust_end_dt, trx_date in financial_vw."
What information did you base this conclusion on. Just because something is in the where clause doesn't mean you should automatically throw an index on it. What if 90% of the rows satisfy those null/not null criteria? What if there's only one year of data in this table? Are you certain an index would help pick out all the data for one month more efficiently than a full table scan?
My immediate question was why are you breaking the data for each month up into separate subqueries like this at all? What is it that your doing with these subqueries that you don't believe can be accomplished with a single grouped query? -
hello friends,
i am supposed to use ST05 and SE30 to do performance tuning,and also perform cost estimation,
can some plz help me understand, i am not that good at reading large paragraphs, so plz donot give me links to help.sap
thank you.Hi
Se30 is the runtime analysis
Here it will give you detailed graph about your program .
abap time,database time application time ..
st05 is sql trace where it will give you individual select stmnts in your program
and also proper index is being used or not.
Other performance tips
check any select stmnts inside the loop and replace with read statement
use binary search in read stmnts
use proper index in where condition in select stmnt.
if you want to execute st05..go st05..trace on-execute ur program--come to st05..trace off and --list trace...
you get summary details of select queires and it will be pink or other color.
Thanks -
Query Performance Tuning - Help
Hello Experts,
Good Day to all...
TEST@ora10g>select * from v$version;
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
"CORE 10.2.0.4.0 Production"
TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
NLSRTL Version 10.2.0.4.0 - Production
SELECT fa.user_id,
fa.notation_type,
MAX(fa.created_date) maxDate,
COUNT(*) bk_count
FROM book_notations fa
WHERE fa.user_id IN
( SELECT user_id
FROM
( SELECT /*+ INDEX(f2,FBK_AN_ID_IDX) */ f2.user_id,
MAX(f2.notatn_id) f2_annotation_id
FROM book_notations f2,
title_relation tdpr
WHERE f2.user_id IN ('100002616221644',
'100002616221645',
'100002616221646',
'100002616221647',
'100002616221648')
AND f2.pack_id=tdpr.pack_id
AND tdpr.title_id =93402
GROUP BY f2.user_id
ORDER BY 2 DESC)
WHERE ROWNUM <= 10)
GROUP BY fa.user_id,
fa.notation_type
ORDER BY 3 DESC;Cost of the Query is too much...
Below is the explain plan of the query
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 29 | 1305 | 52 (10)| 00:00:01 |
| 1 | SORT ORDER BY | | 29 | 1305 | 52 (10)| 00:00:01 |
| 2 | HASH GROUP BY | | 29 | 1305 | 52 (10)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID | book_notations | 11 | 319 | 4 (0)| 00:00:01 |
| 4 | NESTED LOOPS | | 53 | 2385 | 50 (6)| 00:00:01 |
| 5 | VIEW | VW_NSO_1 | 5 | 80 | 29 (7)| 00:00:01 |
| 6 | HASH UNIQUE | | 5 | 80 | | |
|* 7 | COUNT STOPKEY | | | | | |
| 8 | VIEW | | 5 | 80 | 29 (7)| 00:00:01 |
|* 9 | SORT ORDER BY STOPKEY | | 5 | 180 | 29 (7)| 00:00:01 |
| 10 | HASH GROUP BY | | 5 | 180 | 29 (7)| 00:00:01 |
| 11 | TABLE ACCESS BY INDEX ROWID | book_notations | 5356 | 135K| 26 (0)| 00:00:01 |
| 12 | NESTED LOOPS | | 6917 | 243K| 27 (0)| 00:00:01 |
| 13 | MAT_VIEW ACCESS BY INDEX ROWID| title_relation | 1 | 10 | 1 (0)| 00:00:01 |
|* 14 | INDEX RANGE SCAN | IDX_TITLE_ID | 1 | | 1 (0)| 00:00:01 |
| 15 | INLIST ITERATOR | | | | | |
|* 16 | INDEX RANGE SCAN | FBK_AN_ID_IDX | 5356 | | 4 (0)| 00:00:01 |
|* 17 | INDEX RANGE SCAN | FBK_AN_ID_IDX | 746 | | 1 (0)| 00:00:01 |
Table Details
SELECT COUNT(*) FROM book_notations; --111367
Columns
user_id -- nullable field - VARCHAR2(50 BYTE)
pack_id -- NOT NULL --NUMBER
notation_type-- VARCHAR2(50 BYTE) -- nullable field
CREATED_DATE - DATE -- nullable field
notatn_id - VARCHAR2(50 BYTE) -- nullable field
Index
FBK_AN_ID_IDX - Non unique - Composite columns --> (user_id and pack_id)
SELECT COUNT(*) FROM title_relation; --12678
Columns
pack_id - not null - number(38) - PK
title_id - not null - number(38)
Index
IDX_TITLE_ID - Non Unique - TITLE_ID
Please help...
Thanks...Linus wrote:
Thanks Bravid for your reply; highly appreciate that.
So as you say; index creation on the NULL column doesnt have any impact. OK fine.
What happens to the execution plan, performance and the stats when you remove the index hint?
Find below the Execution Plan and Predicate information
"PLAN_TABLE_OUTPUT"
"Plan hash value: 126058086"
"| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |"
"| 0 | SELECT STATEMENT | | 25 | 1125 | 55 (11)| 00:00:01 |"
"| 1 | SORT ORDER BY | | 25 | 1125 | 55 (11)| 00:00:01 |"
"| 2 | HASH GROUP BY | | 25 | 1125 | 55 (11)| 00:00:01 |"
"| 3 | TABLE ACCESS BY INDEX ROWID | book_notations | 10 | 290 | 4 (0)| 00:00:01 |"
"| 4 | NESTED LOOPS | | 50 | 2250 | 53 (8)| 00:00:01 |"
"| 5 | VIEW | VW_NSO_1 | 5 | 80 | 32 (10)| 00:00:01 |"
"| 6 | HASH UNIQUE | | 5 | 80 | | |"
"|* 7 | COUNT STOPKEY | | | | | |"
"| 8 | VIEW | | 5 | 80 | 32 (10)| 00:00:01 |"
"|* 9 | SORT ORDER BY STOPKEY | | 5 | 180 | 32 (10)| 00:00:01 |"
"| 10 | HASH GROUP BY | | 5 | 180 | 32 (10)| 00:00:01 |"
"| 11 | TABLE ACCESS BY INDEX ROWID | book_notations | 5875 | 149K| 28 (0)| 00:00:01 |"
"| 12 | NESTED LOOPS | | 7587 | 266K| 29 (0)| 00:00:01 |"
"| 13 | MAT_VIEW ACCESS BY INDEX ROWID| title_relation | 1 | 10 | 1 (0)| 00:00:01 |"
"|* 14 | INDEX RANGE SCAN | IDX_TITLE_ID | 1 | | 1 (0)| 00:00:01 |"
"| 15 | INLIST ITERATOR | | | | | |"
"|* 16 | INDEX RANGE SCAN | FBK_AN_ID_IDX | 5875 | | 4 (0)| 00:00:01 |"
"|* 17 | INDEX RANGE SCAN | FBK_AN_ID_IDX | 775 | | 1 (0)| 00:00:01 |"
"Predicate Information (identified by operation id):"
" 7 - filter(ROWNUM<=10)"
" 9 - filter(ROWNUM<=10)"
" 14 - access(""TDPR"".""TITLE_ID""=93402)"
" 16 - access((""F2"".""USER_ID""='100002616221644' OR ""F2"".""USER_ID""='100002616221645' OR "
" ""F2"".""USER_ID""='100002616221646' OR ""F2"".""USER_ID""='100002616221647' OR "
" ""F2"".""USER_ID""='100002616221648') AND ""F2"".""PACK_ID""=""TDPR"".""PACK_ID"")"
" 17 - access(""FA"".""USER_ID""=""$nso_col_1"")"
The cost is the same because the plan is the same. The optimiser chose to use that index anyway. The point is, now that you have removed it, the optimiser is free to choose other indexes or a full table scan if it wants to.
>
Statistics
BEGIN
DBMS_STATS.GATHER_TABLE_STATS ('TEST', 'BOOK_NOTATIONS');
END;
"COLUMN_NAME" "NUM_DISTINCT" "NUM_BUCKETS" "HISTOGRAM"
"NOTATION_ID" 110269 1 "NONE"
"USER_ID" 213 212 "FREQUENCY"
"PACK_ID" 20 20 "FREQUENCY"
"NOTATION_TYPE" 8 8 "FREQUENCY"
"CREATED_DATE" 87 87 "FREQUENCY"
"CREATED_BY" 1 1 "NONE"
"UPDATED_DATE" 2 1 "NONE"
"UPDATED_BY" 2 1 "NONE"
After removing the hint ; the query still shows the same "COST"
Autotrace
recursive calls 1
db block gets 0
consistent gets 34706
physical reads 0
redo size 0
bytes sent via SQL*Net to client 964
bytes received via SQL*Net from client 1638
SQL*Net roundtrips to/from client 2
sorts (memory) 3
sorts (disk) 0
Output of query
"USER_ID" "NOTATION_TYPE" "MAXDATE" "COUNT"
"100002616221647" "WTF" 08-SEP-11 20000
"100002616221645" "LOL" 08-SEP-11 20000
"100002616221644" "OMG" 08-SEP-11 20000
"100002616221648" "ABC" 08-SEP-11 20000
"100002616221646" "MEH" 08-SEP-11 20000Thanks...I still don't know what we're working towards at the moment. WHat is the current run time? What is the expected run time?
I can't tell you if there's a better way to write this query or if indeed there is another way to write this query because I don't know what it is attempting to achieve.
I can see that you're accessing 100k rows from a 110k row table and it's using an index to look those rows up. That seems like a job for a full table scan rather than index lookups.
David -
I moved our internal application from a P3 500mhz CPU 1U
server to a Duo-Core Xeon 1.6ghz server.
The newer box has a larger HD, more RAM, beefier CPU, yet my
application is running at the same or a smidgen faster than the old
server. Oh, I went from a Win2k, IIS 5.0 box to a Windows Server
2003 running IIS 6, mysql 5.0.
I did a Windows Performance Monitor look-see. I added all the
CF services and watched the graphs do their thing. I noticed that
after I ran query on my application, the jrun service Avg. Req Time
is pinned at 100%. Even several minutes after inactivity on the
box, this process is still at 100%. Anyone know if this is a
causing my performance woes? Anyone know what else I can look at to
increase the speed of the app (barring and serious code rebuild)?
Thanks!
chrisAnyone know what else I can look at to increase the speed of
the app
(barring and serious code rebuild)?
There are some tweaks and tips, but I will let more knowledge
folks
speak to these. But I am afraid you problem maybe a code
issue. From
the brief description I would be concerned there is some kind
of memory
leak thing happening in your code and until you track it down
and plug
it up, no amount of memory or performance tuning is going to
do you much
good. -
Update with subqueries tuning help
I have the following update that does the required job, but undersdtandably it is running really slowly.
update com_mat_stores
set MST_QTY_ISS_TY = (SELECT NVL(SUM(DECODE(COST_CSY_COSTEL, '23', ABS(COST_NO_UNITS) ,
'20', DECODE(SUBSTR(COST_NO_UNITS,1,1), '-', COST_NO_UNITS, COST_NO_UNITS*-1),
'21', COST_NO_UNITS)),0) STK_QTY
FROM COM_COSTS WHERE COST_COST_YEAR = 2009
AND COST_MST_ID = MST_ID AND ((COST_CSY_COSTEL = '23' AND COST_TRANS_CODE = 'M')
OR (COST_CSY_COSTEL IN ('20','21')))),
MST_VAL_ISS_TY = (SELECT NVL(SUM(DECODE(COST_CSY_COSTEL, '23', ABS(COST_VALUE) ,
'20', DECODE(SUBSTR(COST_VALUE,1,1), '-', COST_VALUE, COST_VALUE*-1),
'21', COST_VALUE)),0) STK_VAL
FROM COM_COSTS WHERE COST_COST_YEAR = 2009
AND COST_MST_ID = MST_ID AND ((COST_CSY_COSTEL = '23' AND COST_TRANS_CODE = 'M')
OR (COST_CSY_COSTEL IN ('20','21'))))
where MST_QTY_ISS_TY <> (SELECT NVL(SUM(DECODE(COST_CSY_COSTEL, '23', ABS(COST_NO_UNITS) ,
'20', DECODE(SUBSTR(COST_NO_UNITS,1,1), '-', COST_NO_UNITS, COST_NO_UNITS*-1),
'21', COST_NO_UNITS)),0) STK_QTY
FROM COM_COSTS WHERE COST_COST_YEAR = 2009
AND COST_MST_ID = MST_ID AND ((COST_CSY_COSTEL = '23' AND COST_TRANS_CODE = 'M')
OR (COST_CSY_COSTEL IN ('20','21'))))
OR MST_VAL_ISS_TY <> (SELECT NVL(SUM(DECODE(COST_CSY_COSTEL, '23', ABS(COST_VALUE) ,
'20', DECODE(SUBSTR(COST_VALUE,1,1), '-', COST_VALUE, COST_VALUE*-1),
'21', COST_VALUE)),0) STK_VAL
FROM COM_COSTS WHERE COST_COST_YEAR = 2009
AND COST_MST_ID = MST_ID AND ((COST_CSY_COSTEL = '23' AND COST_TRANS_CODE = 'M')
OR COST_CSY_COSTEL IN ('20','21')));I managed to get a select for the records changed to use an inline view and this is much faster (see below), but I cannot get this select translated into a update statement. Any help or ideas how to change this. The 2 tables in question are quite large COM_MAT_STORES has 34k and com_costs has 90k that match the criteria (7 million in total). I have checked
SELECT MST_ID, MST_MAT_STOCK_CODE, MST_STO_CODE, MST_QTY_ISS_TY, MST_VAL_ISS_TY, STK_QTY, STK_VAL
FROM COM_MAT_STORES, (SELECT COST_MST_ID CMST,
NVL(SUM(DECODE(COST_CSY_COSTEL, '23', ABS(COST_VALUE) ,
'20', DECODE(SUBSTR(COST_VALUE,1,1), '-', COST_VALUE, COST_VALUE*-1),
'21', COST_VALUE)),0) STK_VAL,
NVL(SUM(DECODE(COST_CSY_COSTEL, '23', ABS(COST_NO_UNITS) ,
'20', DECODE(SUBSTR(COST_NO_UNITS,1,1), '-', COST_NO_UNITS, COST_NO_UNITS*-1),
'21', COST_NO_UNITS)),0) STK_QTY
FROM COM_COSTS WHERE COST_COST_YEAR = 2009
AND ((COST_CSY_COSTEL = '23' AND COST_TRANS_CODE = 'M') OR (COST_CSY_COSTEL IN ('20','21')))
GROUP BY COST_MST_ID)
WHERE CMST(+) = MST_ID
AND (NVL(STK_VAL,0) <> MST_VAL_ISS_TY OR NVL(STK_QTY,0) <> MST_QTY_ISS_TY);Here is the explain plan of the update statement
UPDATE STATEMENT CHOOSE 56 34119 443547
UPDATE COMDBA.COM_MAT_STORES
FILTER
TABLE ACCESS(FULL) COMDBA.COM_MAT_STORES ANALYZED 56 34119 443547
SORT(AGGREGATE) 1 37
TABLE ACCESS(BY INDEX ROWID) COMDBA.COM_COSTS 1 25 925
INDEX(RANGE SCAN) COMDBA.COM_COST_14 2 97476
SORT(AGGREGATE) 1 37
TABLE ACCESS(BY INDEX ROWID) COMDBA.COM_COSTS 1 25 925
INDEX(RANGE SCAN) COMDBA.COM_COST_14 2 97476
SORT(AGGREGATE) 1 37
TABLE ACCESS(BY INDEX ROWID) COMDBA.COM_COSTS 1 25 925
INDEX(RANGE SCAN) COMDBA.COM_COST_14 2 97476
SORT(AGGREGATE) 1 37
TABLE ACCESS(BY INDEX ROWID) COMDBA.COM_COSTS 1 25 925
INDEX(RANGE SCAN) COMDBA.COM_COST_14 2 97476As a first step you can remove the unwanted sub queries.
update com_mat_stores
set (
mst_qty_iss_ty,
mst_val_iss_ty
) =
select nvl(sum(decode(cost_csy_costel, '23', abs(cost_no_units),
'20', decode(substr(cost_no_units,1,1), '-', cost_no_units, cost_no_units*-1),
'21', cost_no_units)),0) stk_qty,
nvl(sum(decode(cost_csy_costel, '23', abs(cost_value) ,
'20', decode(substr(cost_value,1,1), '-', cost_value, cost_value*-1),
'21', cost_value)),0) stk_val
from com_costs
where cost_cost_year = 2009
and cost_mst_id = mst_id
and (
(cost_csy_costel = '23' and cost_trans_code = 'm')
or
(cost_csy_costel in ('20','21'))
where (mst_qty_iss_ty, mst_val_iss_ty) !=
select nvl(sum(decode(cost_csy_costel, '23', abs(cost_no_units) ,
'20', decode(substr(cost_no_units,1,1), '-', cost_no_units, cost_no_units*-1),
'21', cost_no_units)),0) stk_qty,
nvl(sum(decode(cost_csy_costel, '23', abs(cost_value) ,
'20', decode(substr(cost_value,1,1), '-', cost_value, cost_value*-1),
'21', cost_value)),0) stk_val
from com_costs
where cost_cost_year = 2009
and cost_mst_id = mst_id
and (
(cost_csy_costel = '23' and cost_trans_code = 'm')
or
(cost_csy_costel in ('20','21'))
) -
Hi,
Below query is taking huge time for returning result(28579 rows 9 mins).IN this query table audit table is partitioned .Here i'm suspecting count (*)is main problem.I'm taking count for pagination, i'm displaying each page 100 rows based on count only i have to do pg nation ..Here year is range partitioned and month is LIST partitioned .Here year,month,school_code and auidt_date only mandatory params rest of them optional.Please advice to improve the performance
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64biQuery
SELECT ia.*--,rank() over(order by year)
,COUNT(year) OVER() AS record_count
-- ROWNUM AS row_num
FROM IBAUDIT.ibis_audit ia
WHERE YEAR = 2012
AND MONTH = 'MAY'
AND audit_date BETWEEN to_date('04/04/2012','dd-mm-yyyy') AND to_date('04/04/2013','dd-mm-yyyy')
AND school = '000008'
AND (:i_candidate IS NULL
OR candidate = :i_candidate)
AND (:i_user IS NULL
OR person_code = :i_user)
AND (:i_person IS NULL
OR active_person_code = :i_person)
AND (:i_element IS NULL
OR element = :i_element)
AND (:i_action IS NULL
OR DECODE(action, 'INSERT', 'ADD', 'UPDATE', 'CHANGE', action) = UPPER(:i_action))
AND EXISTS
(SELECT 1
FROM IBIS.subject_component sc
WHERE sc.year = 2012
AND sc.month = 'MAY'
AND sc.paper_code = ia.paper_code
AND (:i_subject IS NULL
OR sc.subject = :i_subject)
AND (:i_subject_option IS NULL
OR sc.subject_option = :i_subject_option)
AND (:i_lvl IS NULL
OR sc.lvl = :i_lvl)
AND (:i_component IS NULL
OR sc.component = :i_component)
explan
line 1: SQLPLUS Command Skipped: set linesize 130
line 2: SQLPLUS Command Skipped: set pagesize 0
PLAN_TABLE_OUTPUT
Plan hash value: 2770926248
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1 | 369 | 2601 (28)| 00:00:23 | | |
| 1 | WINDOW BUFFER | | 1 | 369 | 2601 (28)| 00:00:23 | | |
|* 2 | TABLE ACCESS BY LOCAL INDEX ROWID | IBIS_AUDIT | 1 | 294 | 2601 (28)| 00:00:23 | 181 | 181 |
| 3 | NESTED LOOPS | | 1 | 369 | 2601 (28)| 00:00:23 | | |
| 4 | SORT UNIQUE | | 1 | 75 | 44 (0)| 00:00:01 | | |
|* 5 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 75 | 44 (0)| 00:00:01 | | |
|* 6 | INDEX RANGE SCAN | SUBJECT_COMPONENT_ASSESS_TYPE | 1131 | | 8 (0)| 00:00:01 | | |
| 7 | PARTITION RANGE SINGLE | | | | | | 37 | 37 |
| 8 | PARTITION LIST SINGLE | | | | | | KEY | KEY |
| 9 | BITMAP CONVERSION TO ROWIDS | | | | | | | |
| 10 | BITMAP AND | | | | | | | |
| 11 | BITMAP CONVERSION FROM ROWIDS| | | | | | | |
|* 12 | INDEX RANGE SCAN | IBIS_AUDIT_SCHOOL | 21826 | | 33 (4)| 00:00:01 | 181 | 181 |
| 13 | BITMAP CONVERSION FROM ROWIDS| | | | | | | |
|* 14 | INDEX RANGE SCAN | IBIS_AUDIT_PAPER | 21826 | | 84 (4)| 00:00:01 | 181 | 181 |
Predicate Information (identified by operation id):
2 - filter("YEAR"=2012 AND (:I_CANDIDATE IS NULL OR "CANDIDATE"=:I_CANDIDATE) AND (:I_USER IS NULL OR
"PERSON_CODE"=:I_USER) AND (:I_PERSON IS NULL OR "ACTIVE_PERSON_CODE"=:I_PERSON) AND (:I_ELEMENT IS NULL OR
"ELEMENT"=:I_ELEMENT) AND "AUDIT_DATE">=TO_DATE('2012-04-04 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND (:I_ACTION IS NULL OR
DECODE("ACTION",'INSERT','ADD','UPDATE','CHANGE',"ACTION")=UPPER(:I_ACTION)) AND "AUDIT_DATE"<=TO_DATE('2013-04-04 00:00:00',
'yyyy-mm-dd hh24:mi:ss') AND "SC"."YEAR"="IA"."YEAR" AND "SC"."MONTH"="IA"."MONTH")
5 - filter((:I_SUBJECT_OPTION IS NULL OR "SC"."SUBJECT_OPTION"=:I_SUBJECT_OPTION) AND (:I_SUBJECT IS NULL OR
"SC"."SUBJECT"=:I_SUBJECT) AND (:I_COMPONENT IS NULL OR "SC"."COMPONENT"=:I_COMPONENT) AND ("SC"."LVL"=:I_LVL OR :I_LVL IS
NULL))
6 - access("SC"."YEAR"=2012 AND "SC"."MONTH"='MAY')
12 - access("SCHOOL"='000008')
14 - access("SC"."PAPER_CODE"="IA"."PAPER_CODE")
36 rows selecteduser575115 wrote:
Hi,
Below query is taking huge time for returning result(28579 rows 9 mins).IN this query table audit table is partitioned .Here i'm suspecting count (*)is main problem.I'm taking count for pagination, i'm displaying each page 100 rows based on count only i have to do pg nation ..Here year is range partitioned and month is LIST partitioned .Here year,month,school_code and auidt_date only mandatory params rest of them optional.Please advice to improve the performance
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64biQuery
SELECT ia.*--,rank() over(order by year)
,COUNT(year) OVER() AS record_count
-- ROWNUM AS row_num
FROM IBAUDIT.ibis_audit ia
WHERE YEAR = 2012
AND MONTH = 'MAY'
AND audit_date BETWEEN to_date('04/04/2012','dd-mm-yyyy') AND to_date('04/04/2013','dd-mm-yyyy')
AND school = '000008'
AND (:i_candidate IS NULL
OR candidate = :i_candidate)
AND (:i_user IS NULL
OR person_code = :i_user)
AND (:i_person IS NULL
OR active_person_code = :i_person)
AND (:i_element IS NULL
OR element = :i_element)
AND (:i_action IS NULL
OR DECODE(action, 'INSERT', 'ADD', 'UPDATE', 'CHANGE', action) = UPPER(:i_action))
AND EXISTS
(SELECT 1
FROM IBIS.subject_component sc
WHERE sc.year = 2012
AND sc.month = 'MAY'
AND sc.paper_code = ia.paper_code
AND (:i_subject IS NULL
OR sc.subject = :i_subject)
AND (:i_subject_option IS NULL
OR sc.subject_option = :i_subject_option)
AND (:i_lvl IS NULL
OR sc.lvl = :i_lvl)
AND (:i_component IS NULL
OR sc.component = :i_component)
);explan
PLAN_TABLE_OUTPUT
Plan hash value: 2770926248
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1 | 369 | 2601 (28)| 00:00:23 | | |
| 1 | WINDOW BUFFER | | 1 | 369 | 2601 (28)| 00:00:23 | | |
|* 2 | TABLE ACCESS BY LOCAL INDEX ROWID | IBIS_AUDIT | 1 | 294 | 2601 (28)| 00:00:23 | 181 | 181 |
| 3 | NESTED LOOPS | | 1 | 369 | 2601 (28)| 00:00:23 | | |
| 4 | SORT UNIQUE | | 1 | 75 | 44 (0)| 00:00:01 | | |
|* 5 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 75 | 44 (0)| 00:00:01 | | |
|* 6 | INDEX RANGE SCAN | SUBJECT_COMPONENT_ASSESS_TYPE | 1131 | | 8 (0)| 00:00:01 | | |
| 7 | PARTITION RANGE SINGLE | | | | | | 37 | 37 |
| 8 | PARTITION LIST SINGLE | | | | | | KEY | KEY |
| 9 | BITMAP CONVERSION TO ROWIDS | | | | | | | |
| 10 | BITMAP AND | | | | | | | |
| 11 | BITMAP CONVERSION FROM ROWIDS| | | | | | | |
|* 12 | INDEX RANGE SCAN | IBIS_AUDIT_SCHOOL | 21826 | | 33 (4)| 00:00:01 | 181 | 181 |
| 13 | BITMAP CONVERSION FROM ROWIDS| | | | | | | |
|* 14 | INDEX RANGE SCAN | IBIS_AUDIT_PAPER | 21826 | | 84 (4)| 00:00:01 | 181 | 181 |
Predicate Information (identified by operation id):
2 - filter("YEAR"=2012 AND (:I_CANDIDATE IS NULL OR "CANDIDATE"=:I_CANDIDATE) AND (:I_USER IS NULL OR
"PERSON_CODE"=:I_USER) AND (:I_PERSON IS NULL OR "ACTIVE_PERSON_CODE"=:I_PERSON) AND (:I_ELEMENT IS NULL OR
"ELEMENT"=:I_ELEMENT) AND "AUDIT_DATE">=TO_DATE('2012-04-04 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND (:I_ACTION IS NULL OR
DECODE("ACTION",'INSERT','ADD','UPDATE','CHANGE',"ACTION")=UPPER(:I_ACTION)) AND "AUDIT_DATE"<=TO_DATE('2013-04-04 00:00:00',
'yyyy-mm-dd hh24:mi:ss') AND "SC"."YEAR"="IA"."YEAR" AND "SC"."MONTH"="IA"."MONTH")
5 - filter((:I_SUBJECT_OPTION IS NULL OR "SC"."SUBJECT_OPTION"=:I_SUBJECT_OPTION) AND (:I_SUBJECT IS NULL OR
"SC"."SUBJECT"=:I_SUBJECT) AND (:I_COMPONENT IS NULL OR "SC"."COMPONENT"=:I_COMPONENT) AND ("SC"."LVL"=:I_LVL OR :I_LVL IS
NULL))
6 - access("SC"."YEAR"=2012 AND "SC"."MONTH"='MAY')
12 - access("SCHOOL"='000008')
14 - access("SC"."PAPER_CODE"="IA"."PAPER_CODE")
36 rows selected
Plan operations look okay although the Nested Loops operation in step 3 looks out of place - would a hash join work better with the bitmaps? Partition elimination looks great! The series of 1 values at the top of the plan in steps 0-4 suggests something is wrong with either the statistics or the optimizer's processing of the query; you are really getting a lot more rows than the optimizer is estimating.
You reported the query runs faster without the COUNT() which you need. How much faster?
AND and OR conditions mixed together in WHERE clause can add overhead. Would using NVL() instead of the AND/OR combinations affect performance (beware index supression)?
The estimated statistics disappear reading the plan from bottom to the top in step 11. Are all of the objects in the plan - tables and indexes both - analyzed with current values? In particular the # of rows in step 2 for IBIS_AUDIT looks odd - 1 row (possibly correct)? Similarly the estimated values ifor the index lookup in step 5 look low.
If necessary a materialized view with automatic query rewrite (provided that this works) is an option but tuning the SQL is a better idea. -
Hi,
I have aquery which looks like this
CREATE TABLE BKP3
PARALLEL(DEGREE 4 INSTANCES 1)
NOLOGGING
AS
SELECT /* + PARALLEL(4,1) */ *
FROM BKP2 A
WHERE A.COL1 NOT IN (SELECT /* + PARALLEL(4,1) */ COL1
FROM BKP1)
AND A.COL2 NOT IN (SELECT /* + PARALLEL(4,1) */ COL2
FROM BKP1)
AND ROWNUM<=5000000;
Table BKP1 holds more than 5million rows and table BKP2 holds more than 60million rows.
This query is very slow. Is there any way i can improve the performance.
Kindly help.> I dont know how but somehow i am unable to run the explain plan.
What have you tried and what error did you get?
What is your Oracle version?
In 10g I think sys.plan_table$ is granted public access by default. Try using this handy Explain Plan script in SQL*Plus:
www.williamrobertson.net/code/xplan.sql -
Hey to all
I’m currently working to optimize a query for this purpose I learnt how to read execution plan than further more I have studied details of plan table and successful in extracting the Run time statistic like START, EROW, AROW. I accomplished many more thing like when index use, how to use HINTS. When I have covered all things I return to my query to check and tune now but I’m still unable to tune. I think more effort is required. But many question has been gathered during this process plz help by answered my question
My first question is without executing query our execution plan give us right information
Let me elaborate my point I compile query in PL/SQL developer after I checked my execution plan it show FTS. I add hint in query to use index and check plan It show me index scan instead of FST but when I execute the query I did not use index scan why ?
Second question is I gave some select privilege to user which necessary to extract runtime static V_$SQL_PLAN_STATISTICS_ALL, V_$statname, V_$SESSION, V_$SQL_PLAN, V_$statname, V_$sesstat . but when I execute query TOAD give me msg to have V_$sesstat, V$statname, privilege to sql trace. I’m also post my query and execution plan or table counts plz help me to tune this query all table column have index except the column use in where clause.
Explain plan for
Select from ( select ROUND (TkNayaStar.TkNayaStar_DG0.STORE_CODE,0) AS "F1" , TkNayaStar.TkNayaStar_DG0.STORE_NAME AS "F2" ,*
TkNayaStar.TkNayaStar_DG1.TXN_DATE AS "F3" , ROUND (TkNayaStar.TkNayaStar_DG0.TILL_LOCAL_CODE,0) AS "F4" ,
ROUND (TkNayaStar.TkNayaStar_DG1.TXN_NO,0) AS "F5" , TkNayaStar.TkNayaStar_DG1.TXN_TIME AS "F6" , TkNayaStar.TkNayaStar_DG0.RECEIPT_ID AS "F7" ,
ROUND (TkNayaStar.TkNayaStar_DG0.OPERATOR_CODE,0) AS "F8" , ROUND (TkNayaStar.TkNayaStar_DG1.LINE_SOURCE_RT_CODE,0) AS "F9" ,
TkNayaStar.TkNayaStar_DG1.LINE_SOURCE_RT_NAME AS "F10" , ROUND (TkNayaStar.TkNayaStar_DG0.LINE_REC_SEQ,0) AS "F11" , TkNayaStar.TkNayaStar_DG0.LINE_REF AS "F12"
*, ROUND (TkNayaStar.TkNayaStar_DG0.LINE_CODE,0) AS "F13" , ROUND (TkNayaStar.TkNayaStar_DG0.LINE_AMT,2) AS "F14" ,*
ROUND (TkNayaStar.TkNayaStar_DG0.LINE_QTY,3) AS "F15" , TkNayaStar.TkNayaStar_DG0.LINE_VOID_FLAG AS "F16"
from TkNayaStar.TkNayaStar_JT
INNER JOIN TkNayaStar.TkNayaStar_DG0 On TkNayaStar.TkNayaStar_DG0.DG0_ID =TkNayaStar.TkNayaStar_JT.DG0_ID
INNER JOIN TkNayaStar.TkNayaStar_DG1 On TkNayaStar.TkNayaStar_DG1.DG1_ID =TkNayaStar.TkNayaStar_JT.DG1_ID
where ((TkNayaStar.TkNayaStar_DG0.LINE_QTY != 2) )
*) t where RowNum<=10000+1 order by "F5" ASC ,"F1" ASC ,"F3" ASC ,"F4" ASC ,"F6" ASC ,"F11" ASC;*
SELECT * FROM table(dbms_xplan.display_cursor(NULL,NULL,'RUNSTATS_LAST'))
PLAN_TABLE_OUTPUT
SQL_ID 49zp4s4mpxkuy, child number 0
TkNayaStar.TkNayaStar_JT INNER JO
Plan hash value: 559555202
| Id | Operation | Name | Starts | E-Rows
| 0 | SELECT STATEMENT | | 1 |
| 1 | SORT ORDER BY | | 1 | 10001
|* 2 | COUNT STOPKEY | | 1 |
| 3 | PX COORDINATOR | | 1 |
| 4 | PX SEND QC (RANDOM) | :TQ10004 | 0 | 28M
| 5 | BUFFER SORT | | 0 | 10001
|* 6 | COUNT STOPKEY | | 0 |
|* 7 | HASH JOIN | | 0 | 28M
| 8 | PX RECEIVE | | 0 | 42M
| 9 | PX SEND HASH | :TQ10002 | 0 | 42M
|* 10 | HASH JOIN BUFFERED | | 0 | 42M
| 11 | BUFFER SORT | | 0 |
| 12 | PX RECEIVE | | 0 | 42M
| 13 | PX SEND HASH | :TQ10000 | 0 | 42M
| 14 | INDEX FULL SCAN | PKINDX_TKNAYASTAR_JT | 1 | 42M
| 15 | PX RECEIVE | | 0 | 24M
| 16 | PX SEND HASH | :TQ10001 | 0 | 24M
| 17 | PX BLOCK ITERATOR | | 0 | 24M
|* 18 | TABLE ACCESS FULL| TKNAYASTAR_DG1 | 0 | 24M
| 19 | PX RECEIVE | | 0 | 28M
| 20 | PX SEND HASH | :TQ10003 | 0 | 28M
| 21 | PX BLOCK ITERATOR | | 0 | 28M
|* 22 | TABLE ACCESS FULL | TKNAYASTAR_DG0 | 0 | 28M
Predicate Information (identified by operation id):
2 - filter(ROWNUM<=10001)
6 - filter(ROWNUM<=10001)
7 - access("TKNAYASTAR_JT"."DG0_ID"="TKNAYASTAR_DG0"."DG0_ID")
10 - access("TKNAYASTAR_DG1"."DG1_ID"="TKNAYASTAR_JT"."DG1_ID")
18 - access(:Z>=:Z AND :Z<=:Z)
22 - access(:Z>=:Z AND :Z<=:Z)
filter("TKNAYASTAR_DG0"."LINE_QTY"<>2)Can you please post any output like explain plans and queries in { code } tags (w/o the spaces)? It makes it MUCH easier to read.
Thanks! -
I have difficulty in tuning the following query;
SELECT T01.*,T04.address_line,T04.city,T04.state,T05.country_name
FROM v_contact T01 INNER JOIN v_contact_alignment T02
ON T01.contact_id = T02.contact_id
INNER JOIN v_address_affiliation T03
ON T02.affiliation_id = T03.affiliation_id
INNER JOIN v_address T04
ON T03.address_id = T04.address_id
LEFT OUTER JOIN v_m_country T05
ON T04.country_Code = T05.country_code
WHERE T02.alignment_id = 1000004
AND T01.contact_id = 1000236952
ORDER BY T01.last_name ASC, T01.contact_id ASC
The above query takes 104.xx seconds. I fully analyzed all the tables and the number of rows are as follow:
v_contact -> 7490
v_address -> 10480
v_address_affiliation -> 10481
v_contact_alignment -> 1628151
v_m_country -> 231
I created index on v_contact(contact_id) but Oracle doesn't use that index and always perform full table scan. How can I tune the above statement?
Regards,
ChanHi,
I'm quite confusing now. I just omit the v_contact and the query returns 7378 rows in 7.9xx sec.
The query is
SELECT T04.address_line,T04.city,T04.state,T05.country_name
FROM v_contact_alignment T02
INNER JOIN v_address_affiliation T03
ON T02.affiliation_id = T03.affiliation_id
INNER JOIN v_address T04
ON T03.address_id = T04.address_id
LEFT OUTER JOIN v_m_country T05
ON T04.country_Code = T05.country_code
WHERE T02.alignment_id = 1000004 ORDER BY T04.address_line
The explain plan is as follow
SELECT STATEMENT 1347
SORT ORDER BY 1
HASH JOIN OUTER 1
HASH JOIN 1
HASH JOIN 1
TABLE ACCESS FULL CONTACT_ALIGNMENT 1
TABLE ACCESS FULL ADDRESS_AFFILIATION 2
TABLE ACCESS FULL ADDRESS 2
TABLE ACCESS FULL DN_HELP_ITEM 2
Even there are full table scan, it seems OK. But I don't understand why the full table scan for v_contact takes so much time as it only has 7xxx rows.
Any comment is welcome.
Regards,
Chan -
Query tuning help required:
I have a query which is taking long time. Is there any way I can improve the query to shorten its time of execution.
I have given below the details of it.
SQL> set pagesize 1000;
SQL> set linesize 170;
SQL> alter session set events '10046 trace name context forever, level 8';
Session altered.
Elapsed: 00:00:00.25
SQL> SELECT pa.regn_no,
2 (SELECT mst.status_desc
3 FROM m_status mst
4 WHERE mst.trans_id = 'PA01'
5 AND mst.status_code = pa.regn_status) AS regn_status,
6 (SELECT pp.NAME
7 FROM people_profile pp
8 WHERE pp.pp_id = pa.ident_no) AS NAME, pa.ident_no,
9 TO_CHAR (pa.approval_date, 'dd/mm/yyyy') AS approval_date,
10 TO_CHAR (pa.de_reg_date, 'dd/mm/yyyy') AS de_regist_date,
11 TO_CHAR (pa.cert_reg_exp_date, 'dd/mm/yyyy') AS cert_expiry_date,
12 pa.gender, pa.fax_no,
13 (SELECT nationality_desc
14 FROM people_profile pp, m_nationality
15 WHERE pp.pp_id = pa.ident_no
16 AND pp.nationality = nationality_code) AS nationality,
17 (SELECT pp.email_add
18 FROM people_profile pp
19 WHERE pp.pp_id = pa.ident_no) AS email_add,
20 (SELECT pp.mobile_no
21 FROM people_profile pp
22 WHERE pp.pp_id = pa.ident_no) AS mobile_no,
23 TO_CHAR ((SELECT pp.birth_date
24 FROM people_profile pp
25 WHERE pp.pp_id = pa.ident_no),
26 'dd/mm/yyyy'
27 ) AS birth_date,
28 REPLACE (sf_get_address_people (pa.ident_no, '2', 'C'),
29 '<br>',
30 CHR (10)
31 ) AS address,
32 sf_get_pa_firm_info (pa.ident_no) AS firm_profile,
33 sf_get_pa_firm_partner (pa.ident_no) AS firm_partner,
34 sf_get_pa_pmp_code (pa.ident_no) AS pmp_code, ppv.pae_name,
35 ppv.pmp_code AS pmp_code_1, ppv.cycle_no, ppv.seq_no,
36 DECODE (ppv.visit_type,
37 'I', 'INITIAL',
38 'R', 'REVISIT',
39 ''
40 ) AS visit_type,
41 TO_CHAR (ppv.initial_ltr_date, 'dd/mm/yyyy') AS initial_ltr_date,
42 TO_CHAR (ppv.sec_ltr_date, 'dd/mm/yyyy') AS sec_ltr_date,
43 TO_CHAR (ppv.review_from, 'dd/mm/yyyy') AS review_from,
44 TO_CHAR (ppv.review_to, 'dd/mm/yyyy') AS review_to,
45 TO_CHAR (ppv.finding_date, 'dd/mm/yyyy') AS finding_date,
46 TO_CHAR (ppv.finding_due_date, 'dd/mm/yyyy') AS finding_due_date,
47 TO_CHAR (ppv.finding_reply_date,
48 'dd/mm/yyyy'
49 ) AS finding_reply_date,
50 ppv.pmsc,
51 TO_CHAR (ppv.clarif_ltr_date, 'dd/mm/yyyy') AS clarif_ltr_date,
52 ppv.paoc_date,
53 TO_CHAR (ppv.final_paoc_date, 'dd/mm/yyyy') AS final_paoc_date,
54 (SELECT result_desc
55 FROM m_pmp_result ms
56 WHERE result_id = ppv.pmp_status) AS pmp_status,
57 TO_CHAR (ppv.suspension_end_date,
58 'dd/mm/yyyy'
59 ) AS suspension_end_date,
60 TO_CHAR (ppv.final_ltr_date, 'dd/mm/yyyy') AS final_ltr_date,
61 ppv.findings_summary,
62 TO_CHAR (ppv.invoice_date, 'dd/mm/yyyy') AS invoice_date,
63 ppv.amount_billed,
64 TO_CHAR (ppv.payment_date, 'dd/mm/yyyy') AS payment_date,
65 DECODE (ppv.pay_icpas,
66 'Y', 'YES',
67 'N', 'NO',
68 'V', 'NA',
69 ''
70 ) AS pay_icpas,
71 ppv.updated_date, ppv.updated_by, ppv.remarks,
72 DECODE ((SELECT ppr.review_status
73 FROM pa_pmp_reviews ppr
74 WHERE ppr.regn_no = ppv.regn_no
75 AND ppr.cycle_no = ppv.cycle_no),
76 'P', 'In Progress',
77 'C', 'Closed',
78 ''
79 ) AS review_status,
80 pcl.complaint_no,
81 DECODE (pcl.complaint_status,
82 'P', 'Pending',
83 'C', 'Closed',
84 ''
85 ) AS complaint_status,
86 pcl.remarks AS remarks_1,
87 DECODE (pcl.complaint_outcome,
88 'C', 'Cancelled',
89 'R', 'Restriction of Practice',
90 'P', 'Penalty (Fine) - Disciplinary',
91 'E', 'Censure - Disciplinary',
92 'S', 'Suspended - Disciplinary',
93 ''
94 ) AS complaint_outcome,
95 TO_CHAR (pcl.complaint_date, 'dd/mm/yyyy') AS complaint_date,
96 pcl.complainant_nric, pcl.complainant_name, pcl.complaint_details,
97 TO_CHAR (pcl.effective_date, 'dd/mm/yyyy') AS effective_date,
98 TO_CHAR (pcl.effective_date_to,
99 'dd/mm/yyyy') AS effective_date_to,
100 sf_get_pa_exam_info (pa.regn_no, 'L') AS local_exam_detail,
101 sf_get_pa_exam_info (pa.regn_no, 'F') AS foreign_exam_detail,
102 sf_get_pa_exempt_info (pa.regn_no) AS exempt_detail
103 FROM pa_profile pa, pa_pmp_visits ppv, pa_complaint pcl
104 WHERE pa.regn_no = ppv.regn_no(+) AND pa.regn_no = pcl.regn_no(+)
105 ORDER BY pa.regn_no DESC;
1163 rows selected.
Elapsed: 00:02:08.87
Execution Plan
Plan hash value: 2912197266
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1109 | 330K| 17 (12)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID | M_STATUS | 1 | 23 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | PK_M_STATUS | 1 | | 1 (0)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID | PEOPLE_PROFILE | 1 | 25 | 3 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | SYS_C00103408 | 1 | | 2 (0)| 00:00:01 |
| 5 | NESTED LOOPS | | 1 | 26 | 4 (0)| 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID| PEOPLE_PROFILE | 1 | 12 | 3 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | SYS_C00103408 | 1 | | 2 (0)| 00:00:01 |
|* 8 | INDEX RANGE SCAN | PK_M_NATIONALITY | 1 | 14 | 1 (0)| 00:00:01 |
| 9 | TABLE ACCESS BY INDEX ROWID | PEOPLE_PROFILE | 1 | 20 | 3 (0)| 00:00:01 |
|* 10 | INDEX UNIQUE SCAN | SYS_C00103408 | 1 | | 2 (0)| 00:00:01 |
| 11 | TABLE ACCESS BY INDEX ROWID | PEOPLE_PROFILE | 1 | 11 | 3 (0)| 00:00:01 |
|* 12 | INDEX UNIQUE SCAN | SYS_C00103408 | 1 | | 2 (0)| 00:00:01 |
| 13 | TABLE ACCESS BY INDEX ROWID | PEOPLE_PROFILE | 1 | 10 | 3 (0)| 00:00:01 |
|* 14 | INDEX UNIQUE SCAN | SYS_C00103408 | 1 | | 2 (0)| 00:00:01 |
| 15 | TABLE ACCESS BY INDEX ROWID | M_PMP_RESULT | 1 | 37 | 1 (0)| 00:00:01 |
|* 16 | INDEX UNIQUE SCAN | XPK_M_PMP_RESULT | 1 | | 0 (0)| 00:00:01 |
| 17 | TABLE ACCESS BY INDEX ROWID | PA_PMP_REVIEWS | 1 | 8 | 1 (0)| 00:00:01 |
|* 18 | INDEX UNIQUE SCAN | SYS_C00103321 | 1 | | 0 (0)| 00:00:01 |
| 19 | SORT ORDER BY | | 1109 | 330K| 17 (12)| 00:00:01 |
|* 20 | HASH JOIN RIGHT OUTER | | 1109 | 330K| 16 (7)| 00:00:01 |
| 21 | TABLE ACCESS FULL | PA_COMPLAINT | 146 | 20294 | 3 (0)| 00:00:01 |
|* 22 | HASH JOIN RIGHT OUTER | | 1109 | 179K| 13 (8)| 00:00:01 |
| 23 | TABLE ACCESS FULL | PA_PMP_VISITS | 90 | 11340 | 3 (0)| 00:00:01 |
| 24 | TABLE ACCESS FULL | PA_PROFILE | 1109 | 44360 | 9 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("MST"."TRANS_ID"='PA01' AND "MST"."STATUS_CODE"=:B1)
filter("MST"."STATUS_CODE"=:B1)
4 - access("PP"."PP_ID"=:B1)
7 - access("PP"."PP_ID"=:B1)
8 - access("PP"."NATIONALITY"="NATIONALITY_CODE")
10 - access("PP"."PP_ID"=:B1)
12 - access("PP"."PP_ID"=:B1)
14 - access("PP"."PP_ID"=:B1)
16 - access("RESULT_ID"=:B1)
18 - access("PPR"."REGN_NO"=:B1 AND "PPR"."CYCLE_NO"=:B2)
20 - access("PA"."REGN_NO"="PCL"."REGN_NO"(+))
22 - access("PA"."REGN_NO"="PPV"."REGN_NO"(+))
Statistics
17577 recursive calls
0 db block gets
8703644 consistent gets
6138 physical reads
0 redo size
424453 bytes sent via SQL*Net to client
3641 bytes received via SQL*Net from client
13 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1163 rows processed
NAME TYPE VALUE
user_dump_dest string /opt/app/oracle/diag/rdbms/ebi
zfile/EBIZFILE/trace
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_capture_sql_plan_baselines boolean FALSE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 11.2.0.1
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
optimizer_use_invisible_indexes boolean FALSE
optimizer_use_pending_statistics boolean FALSE
optimizer_use_sql_plan_baselines boolean TRUE
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 128
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
SQL> show parameter cursor_sharing
NAME TYPE VALUE
cursor_sharing string EXACT
SQL>
SQL> column sname format a20
SQL> column pname format a20
SQL> column pval2 format a20
SQL>
SQL> select
2 sname, pname, pval1, pval2
3 from
4 sys.aux_stats$;
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 11-20-2009 09:46
SYSSTATS_INFO DSTOP 11-20-2009 09:46
SYSSTATS_INFO FLAGS 1
SYSSTATS_MAIN CPUSPEEDNW 1676.76768
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SYSSTATS_MAIN MAXTHR
SYSSTATS_MAIN SLAVETHRHi,
obviously the problem you are having is described by the following lines of your execution plan
SORT ORDER BY | | 1109 | 330K| 17 (12)| 00:00:01 |
|* 20 | HASH JOIN RIGHT OUTER | | 1109 | 330K| 16 (7)| 00:00:01 |
| 21 | TABLE ACCESS FULL | PA_COMPLAINT | 146 | 20294 | 3 (0)| 00:00:01 |
|* 22 | HASH JOIN RIGHT OUTER | | 1109 | 179K| 13 (8)| 00:00:01 |
| 23 | TABLE ACCESS FULL | PA_PMP_VISITS | 90 | 11340 | 3 (0)| 00:00:01 |
| 24 | TABLE ACCESS FULL | PA_PROFILE | 1109 | 44360 | 9
You don't have a "real" "WHERE" condition in the query that could lead the Oracle CBO to consider using an index.
This leads to a full scan of PA_PMP_VISITS and PA_PROFILE and subsequently -in order to process the join condition between these two tables-
to this "HASH JOIN RIGHT OUTER". You cannot avoid this, with the current WHERE condition ...
Following thoughts :
1) Try narrowing down your result set by specifying a "real" WHERE Condition on one of the two tables, specifying an indexed column
2) If this cannot be done, try using query parallelism (parallel hint). This will give you acceptable SQL-execution times.
3) If this is not possible, there would be a third approach : You could consider the definition of an index on "pa.regn" and use a hint on your query in order to use it. Due to your order condition there is a possibility that CBO is going to use it, especially if you specify WHERE ROWNUM < ...
Regards,
Michalis -
Hi ,
11.2.0.1
AIX 6.1
I have following query which is executed from Application,the query comes back within 2 secs for not so common last_name combined with gender but it is taking longer time for common last_names like 'BROWN' or 'JONES' or 'SMITH' with gender_id .
select customerin0_.ROW_NUMBER as ROW1_22596_, customerin0_.ADDRESS_ID as
ADDRESS2_22596_, customerin0_.addressTypeId as addressT3_22596_,
customerin0_.city as city22596_, customerin0_.CONTACT_DETAILS_CODE_ID as
CONTACT5_22596_, customerin0_.county as county22596_, customerin0_.countyID
as countyID22596_, customerin0_.dob as dob22596_, customerin0_.eyecolor as
eyecolor22596_, customerin0_.eyecolorid as eyecolorid22596_,
customerin0_.FIRST_NAME as FIRST11_22596_, customerin0_.gender as
gender22596_, customerin0_.genderid as genderid22596_,
customerin0_.ID_NUMBER as ID14_22596_, customerin0_.JURISDICTION_CODE as
JURISDI15_22596_, customerin0_.LAST_NAME as LAST16_22596_,
customerin0_.LEGAL_ENTITY_ID as LEGAL17_22596_,
customerin0_.LEGAL_ENTITY_NUMBER as LEGAL18_22596_,
customerin0_.LEGAL_ENTITY_TYPE as LEGAL19_22596_, customerin0_.MIDDLE_NAME
as MIDDLE20_22596_, customerin0_.STREET_ADDRESS_1 as STREET21_22596_,
customerin0_.suffix_value as suffix22_22596_, customerin0_.ZIP_CODE as
ZIP23_22596_, customerin0_.ZIP_PLUS_4 as ZIP24_22596_
from
CUSTOMER_IND_SEARCH_VIEW customerin0_ where (customerin0_.LAST_NAME like :1)
and customerin0_.genderid=:2 and rownum<=200
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 18 1.88 123.53 8245 12403 0 179
total 18 1.88 123.53 8245 12403 0 179
Misses in library cache during parse: 0
Parsing user id: 135 (???)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
ges message buffer allocation 259 0.00 0.00
gc cr grant 2-way 259 0.00 0.08
db file sequential read 10126 1.40 148.07
SQL*Net message from client 19 0.02 0.10
SQL*Net message to client 18 0.00 0.00
********************************************************************************Was not able to generate plan out of tkrprof ,captured it from OEM.
10 | NESTED LOOPS | | 805 | 73255 | 3477 (1)| 00:00:42 |
| 11 | NESTED LOOPS | | 805 | 51520 | 1866 (1)| 00:00:23 |
| 12 | NESTED LOOPS | | 805 | 33005 | 254 (0)| 00:00:04 |
|* 13 | TABLE ACCESS BY INDEX ROWID| REF_CONTACT_DETAILS | 1 | 10 | 1 (0)| 00:00:01 |
|* 14 | INDEX UNIQUE SCAN | XAK1_REF_CD_VALUE | 1 | | 0 (0)| |
| 15 | TABLE ACCESS BY INDEX ROWID| PERSON_PROFILE_NAMES | 805 | 24955 | 253 (0)| 00:00:04 |
|* 16 | INDEX RANGE SCAN | IDX$$_D7D50001 | 805 | | 4 (0)| 00:00:01 |
|* 17 | TABLE ACCESS BY INDEX ROWID | PERSON_PROFILE | 1 | 23 | 2 (0)| 00:00:01 |
|* 18 | INDEX UNIQUE SCAN | XPK_PERSON_PROFILE | 1 | | 1 (0)| 00:00:01 |
|* 19 | TABLE ACCESS BY INDEX ROWID | LEGAL_ENTITY | 1 | 27 | 2 (0)| 00:00:01 |
|* 20 | INDEX UNIQUE SCAN | XPK_LEGAL_ENTITY | 1 | | 1 (0)| 00:00:01 |
|* 21 | TABLE ACCESS BY INDEX ROWID | LEGAL_ENTITY_ADDRESSES | 1 | 81 | 3 (0)| 00:00:01 |
|* 22 | INDEX RANGE SCAN | LENUM_CODE_ID | 1 | | 2 (0)| 00:00:01 |
|* 23 | TABLE ACCESS BY INDEX ROWID | LEGAL_ENTITY_IDENTIFICATIONS | 1 | 36 | 3 (0)| 00:00:01 |
|* 24 | INDEX RANGE SCAN | XIF1_LEGAL_ENTITY_ID | 1 | | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("REFCOUNTIES"."ID"=:B1)
4 - access("REFEYECOLORS"."ID"=:B1)
6 - access("REFGENDER"."ID"=:B1)
7 - filter(ROWNUM<=200)
13 - filter("REFCONTACTDETAILS"."MODE_TYPE"=4)
14 - access("REFCONTACTDETAILS"."VALUE"='PRA')
16 - access("PERSONPROFILENAMES"."LAST_NAME" LIKE :1 AND "PERSONPROFILENAMES"."IS_DELETED"=0)
filter(("PERSONPROFILENAMES"."LAST_NAME" LIKE :1 AND "PERSONPROFILENAMES"."IS_DELETED"=0))
17 - filter("SYS_ALIAS_2"."GENDER_ID"=:2)
18 - access("SYS_ALIAS_2"."PP_LEGALENTITY_NUMBER"="PERSONPROFILENAMES"."PP_LEGALENTITY_NUMBER")
19 - filter(("LEGALENTITY"."IS_DELETED"=0 OR "LEGALENTITY"."IS_DELETED"=NULL))
20 - access("LEGALENTITY"."LEGAL_ENTITY_NUMBER"="SYS_ALIAS_2"."PP_LEGALENTITY_NUMBER")
21 - filter("LEGALENTITYADDRESSES"."IS_DELETED"=0)
22 - access("LEGALENTITY"."LEGAL_ENTITY_NUMBER"="LEGALENTITYADDRESSES"."LEGAL_ENTITY_NUMBER" AND
"REFCONTACTDETAILS"."ID"="LEGALENTITYADDRESSES"."CONTACT_DETAILS_CODE_ID")
23 - filter(("LEGAL_ENTITY_ID"."END_DATE">=SYSDATE@! AND "LEGAL_ENTITY_ID"."EFFECTIVE_DATE"<=SYSDATE@!))
24 - access("LEGAL_ENTITY_ID"."LEGAL_ENTITY_NUMBER"="LEGALENTITY"."LEGAL_ENTITY_NUMBER")
Please advice ....
Thanks
Edited by: Monto on Aug 22, 2012 4:22 AMExplain Plan with common name.
SELECT customerin0_.ROW_NUMBER AS ROW1_22596_,
customerin0_.ADDRESS_ID AS ADDRESS2_22596_,
customerin0_.addressTypeId AS addressT3_22596_,
customerin0_.city AS city22596_,
customerin0_.CONTACT_DETAILS_CODE_ID AS CONTACT5_22596_,
customerin0_.county AS county22596_,
customerin0_.countyID AS countyID22596_,
customerin0_.dob AS dob22596_,
customerin0_.eyecolor AS eyecolor22596_,
customerin0_.eyecolorid AS eyecolorid22596_,
customerin0_.FIRST_NAME AS FIRST11_22596_,
customerin0_.gender AS gender22596_,
customerin0_.genderid AS genderid22596_,
customerin0_.ID_NUMBER AS ID14_22596_,
customerin0_.JURISDICTION_CODE AS JURISDI15_22596_,
customerin0_.LAST_NAME AS LAST16_22596_,
customerin0_.LEGAL_ENTITY_ID AS LEGAL17_22596_,
customerin0_.LEGAL_ENTITY_NUMBER AS LEGAL18_22596_,
customerin0_.LEGAL_ENTITY_TYPE AS LEGAL19_22596_,
customerin0_.MIDDLE_NAME AS MIDDLE20_22596_,
customerin0_.STREET_ADDRESS_1 AS STREET21_22596_,
customerin0_.suffix_value AS suffix22_22596_,
customerin0_.ZIP_CODE AS ZIP23_22596_,
customerin0_.ZIP_PLUS_4 AS ZIP24_22596_
FROM xmatapp.CUSTOMER_IND_SEARCH_VIEW customerin0_
WHERE (customerin0_.LAST_NAME LIKE 'SMITH%')
AND customerin0_.genderid = 2
AND ROWNUM <= 200
call count cpu elapsed disk query current rows
Parse 1 0.04 0.05 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 15 5.05 167.51 14050 20246 0 200
total 17 5.09 167.56 14050 20246 0 200
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Rows Row Source Operation
41 TABLE ACCESS BY INDEX ROWID REF_COUNTIES (cr=58 pr=0 pw=0 time=0 us cost=1 size=12 card=1)
41 INDEX UNIQUE SCAN XPK_REF_COUNTIES (cr=17 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 308432)
7 TABLE ACCESS BY INDEX ROWID REF_EYE_COLORS (cr=11 pr=0 pw=0 time=0 us cost=1 size=10 card=1)
7 INDEX UNIQUE SCAN XPK_REF_EYE_COLORS (cr=4 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 308404)
1 TABLE ACCESS BY INDEX ROWID REF_GENDER (cr=2 pr=0 pw=0 time=0 us cost=1 size=9 card=1)
1 INDEX UNIQUE SCAN XPK_REF_GENDER (cr=1 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 308759)
200 COUNT STOPKEY (cr=20175 pr=14050 pw=0 time=2540633 us)
200 NESTED LOOPS OUTER (cr=20175 pr=14050 pw=0 time=2540633 us cost=103 size=1248 card=6)
200 NESTED LOOPS (cr=19756 pr=13775 pw=0 time=17003952 us cost=80 size=1032 card=6)
200 NESTED LOOPS (cr=19304 pr=13586 pw=0 time=14271285 us cost=55 size=1092 card=12)
200 NESTED LOOPS (cr=19017 pr=13453 pw=0 time=13593988 us cost=31 size=768 card=12)
4923 NESTED LOOPS (cr=4640 pr=4614 pw=0 time=63281900 us cost=7 size=492 card=12)
1 TABLE ACCESS BY INDEX ROWID REF_CONTACT_DETAILS (cr=2 pr=0 pw=0 time=0 us cost=1 size=10 card=1)
1 INDEX UNIQUE SCAN XAK1_REF_CD_VALUE (cr=1 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 308425)
4923 TABLE ACCESS BY INDEX ROWID PERSON_PROFILE_NAMES (cr=4638 pr=4614 pw=0 time=63269280 us cost=6 size=372 card=12)
4923 INDEX RANGE SCAN IDX$$_D7D50001 (cr=30 pr=16 pw=0 time=60326 us cost=2 size=0 card=12)(object id 311149)
200 TABLE ACCESS BY INDEX ROWID PERSON_PROFILE (cr=14377 pr=8839 pw=0 time=0 us cost=2 size=23 card=1)
4923 INDEX UNIQUE SCAN XPK_PERSON_PROFILE (cr=9454 pr=4288 pw=0 time=0 us cost=1 size=0 card=1)(object id 308484)
200 TABLE ACCESS BY INDEX ROWID LEGAL_ENTITY (cr=287 pr=133 pw=0 time=0 us cost=2 size=27 card=1)
200 INDEX UNIQUE SCAN XPK_LEGAL_ENTITY (cr=225 pr=80 pw=0 time=0 us cost=1 size=0 card=1)(object id 308494)
200 TABLE ACCESS BY INDEX ROWID LEGAL_ENTITY_ADDRESSES (cr=452 pr=189 pw=0 time=0 us cost=3 size=81 card=1)
200 INDEX RANGE SCAN LENUM_CODE_ID (cr=281 pr=94 pw=0 time=0 us cost=2 size=0 card=1)(object id 307952)
200 TABLE ACCESS BY INDEX ROWID LEGAL_ENTITY_IDENTIFICATIONS (cr=419 pr=275 pw=0 time=0 us cost=4 size=36 card=1)
200 INDEX RANGE SCAN XIF1_LEGAL_ENTITY_ID (cr=219 pr=77 pw=0 time=0 us cost=2 size=0 card=1)(object id 308082)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
ges message buffer allocation 8576 0.00 0.02
library cache lock 7 0.00 0.00
library cache pin 7 0.00 0.00
SQL*Net message to client 15 0.00 0.00
Disk file operations I/O 19 0.01 0.03
gc cr grant 2-way 8554 0.01 3.09
db file sequential read 14050 0.91 158.32
SQL*Net message from client 15 32.28 35.97
gc cr grant congested 8 0.00 0.01
********************************************************************************Plan with rare names.
SELECT customerin0_.ROW_NUMBER AS ROW1_22596_,
customerin0_.ADDRESS_ID AS ADDRESS2_22596_,
customerin0_.addressTypeId AS addressT3_22596_,
customerin0_.city AS city22596_,
customerin0_.CONTACT_DETAILS_CODE_ID AS CONTACT5_22596_,
customerin0_.county AS county22596_,
customerin0_.countyID AS countyID22596_,
customerin0_.dob AS dob22596_,
customerin0_.eyecolor AS eyecolor22596_,
customerin0_.eyecolorid AS eyecolorid22596_,
customerin0_.FIRST_NAME AS FIRST11_22596_,
customerin0_.gender AS gender22596_,
customerin0_.genderid AS genderid22596_,
customerin0_.ID_NUMBER AS ID14_22596_,
customerin0_.JURISDICTION_CODE AS JURISDI15_22596_,
customerin0_.LAST_NAME AS LAST16_22596_,
customerin0_.LEGAL_ENTITY_ID AS LEGAL17_22596_,
customerin0_.LEGAL_ENTITY_NUMBER AS LEGAL18_22596_,
customerin0_.LEGAL_ENTITY_TYPE AS LEGAL19_22596_,
customerin0_.MIDDLE_NAME AS MIDDLE20_22596_,
customerin0_.STREET_ADDRESS_1 AS STREET21_22596_,
customerin0_.suffix_value AS suffix22_22596_,
customerin0_.ZIP_CODE AS ZIP23_22596_,
customerin0_.ZIP_PLUS_4 AS ZIP24_22596_
FROM xmatapp.CUSTOMER_IND_SEARCH_VIEW customerin0_
WHERE (customerin0_.LAST_NAME LIKE 'KUMAR%')
AND customerin0_.genderid = '2'
AND ROWNUM <= 200
call count cpu elapsed disk query current rows
Parse 1 0.05 0.07 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 15 0.02 0.03 0 1829 0 200
total 17 0.07 0.10 0 1829 0 200
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Rows Row Source Operation
23 TABLE ACCESS BY INDEX ROWID REF_COUNTIES (cr=37 pr=0 pw=0 time=0 us cost=1 size=12 card=1)
23 INDEX UNIQUE SCAN XPK_REF_COUNTIES (cr=14 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 308432)
5 TABLE ACCESS BY INDEX ROWID REF_EYE_COLORS (cr=9 pr=0 pw=0 time=0 us cost=1 size=10 card=1)
5 INDEX UNIQUE SCAN XPK_REF_EYE_COLORS (cr=4 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 308404)
1 TABLE ACCESS BY INDEX ROWID REF_GENDER (cr=2 pr=0 pw=0 time=0 us cost=1 size=9 card=1)
1 INDEX UNIQUE SCAN XPK_REF_GENDER (cr=1 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 308759)
200 COUNT STOPKEY (cr=1781 pr=0 pw=0 time=15124 us)
200 NESTED LOOPS OUTER (cr=1781 pr=0 pw=0 time=14726 us cost=103 size=1248 card=6)
200 NESTED LOOPS (cr=1383 pr=0 pw=0 time=35422 us cost=80 size=1032 card=6)
200 NESTED LOOPS (cr=980 pr=0 pw=0 time=20198 us cost=55 size=1092 card=12)
200 NESTED LOOPS (cr=741 pr=0 pw=0 time=15422 us cost=31 size=768 card=12)
289 NESTED LOOPS (cr=129 pr=0 pw=0 time=3648 us cost=7 size=492 card=12)
1 TABLE ACCESS BY INDEX ROWID REF_CONTACT_DETAILS (cr=2 pr=0 pw=0 time=0 us cost=1 size=10 card=1)
1 INDEX UNIQUE SCAN XAK1_REF_CD_VALUE (cr=1 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 308425)
289 TABLE ACCESS BY INDEX ROWID PERSON_PROFILE_NAMES (cr=127 pr=0 pw=0 time=3360 us cost=6 size=372 card=12)
289 INDEX RANGE SCAN IDX$$_D7D50001 (cr=18 pr=0 pw=0 time=672 us cost=2 size=0 card=12)(object id 311149)
200 TABLE ACCESS BY INDEX ROWID PERSON_PROFILE (cr=612 pr=0 pw=0 time=0 us cost=2 size=23 card=1)
289 INDEX UNIQUE SCAN XPK_PERSON_PROFILE (cr=323 pr=0 pw=0 time=0 us cost=1 size=0 card=1)(object id 308484)
200 TABLE ACCESS BY INDEX ROWID LEGAL_ENTITY (cr=239 pr=0 pw=0 time=0 us cost=2 size=27 card=1)
200 INDEX UNIQUE SCAN XPK_LEGAL_ENTITY (cr=194 pr=0 pw=0 time=0 us cost=1 size=0 card=1)(object id 308494)
200 TABLE ACCESS BY INDEX ROWID LEGAL_ENTITY_ADDRESSES (cr=403 pr=0 pw=0 time=0 us cost=3 size=81 card=1)
200 INDEX RANGE SCAN LENUM_CODE_ID (cr=230 pr=0 pw=0 time=0 us cost=2 size=0 card=1)(object id 307952)
200 TABLE ACCESS BY INDEX ROWID LEGAL_ENTITY_IDENTIFICATIONS (cr=398 pr=0 pw=0 time=0 us cost=4 size=36 card=1)
200 INDEX RANGE SCAN XIF1_LEGAL_ENTITY_ID (cr=198 pr=0 pw=0 time=0 us cost=2 size=0 card=1)(object id 308082)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
ges message buffer allocation 14 0.00 0.00
library cache lock 7 0.00 0.00
library cache pin 7 0.00 0.00
KJC: Wait for msg sends to complete 2 0.00 0.00
SQL*Net message to client 15 0.00 0.00
SQL*Net message from client 15 18.88 21.81
********************************************************************************PERSONPROFILENAMES-16 Milion rows
LEGALENTITYADDRESSES-34 Milion rows
PERSONPROFILE-16 Milion rows
LEGALENTITY 17 Milion rows
refcontactdetails 45 rows
Thanks -
I ran the below query two times . first this query run within 4 minutes now it is running withing 20 minutes only . and how can I reduce the running time of this query.
my first table TABLE1 has partitioned day wise.
Total 14 partition in TABLE1 so if it runs for total 14 partitions it will take 14*20= 280 minutes.
Index created for TABLE1 and TABLE2
CREATE INDEX TABLE1_COL_A_INX ON TABLE1(COL_A);
CREATE INDEX TABLE1_COL_B_INX ON TABLE1(COL_B);
CREATE INDEX TABLE2_BNO_TYP_INX ON TABLE2(COL_B,RECORD_TYP);TABLE1 contain 3 billion records
TABLE2 contain 87 thousand records
INSERT INTO TARGET_TABLE
SELECT t1.col_A,
t1.col_b,
t1.record_typ,
TO_date('14/06/2012','DD/MM/YYYY') ,
MIN( start_dt) AS First_Seen,
MAX( start_dt) AS Last_Seen
FROM TABLE1 t1,
TABLE2 t2
WHERE t1.start_dt = TO_date('14/06/2012','DD/MM/YYYY') - 12
AND t1.col_b = t2.col_b
AND t1.record_typ = t2.record_typ
GROUP BY t1.col_a,t1.col_b,t1.record_typ,TO_date('14/06/2012','DD/MM/YYYY') ;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
Explain plan with statistics
SQL>
117794 rows selected.
Execution Plan
Plan hash value: 1844245574
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 147K| 7362K| | 615K (1)| 02:03:05 | | |
| 1 | HASH GROUP BY | | 147K| 7362K| 9320K| 615K (1)| 02:03:05 | | |
| 2 | NESTED LOOPS | | | | | | | | |
| 3 | NESTED LOOPS | | 147K| 7362K| | 613K (1)| 02:02:43 | | |
| 4 | TABLE ACCESS FULL | TABEL2 | 87586 | 1282K| | 137 (1)| 00:00:02 | | |
| 5 | PARTITION RANGE SINGLE | | 3 | | | 3 (0)| 00:00:01 | 4 | 4 |
|* 6 | INDEX RANGE SCAN | TABLE1_COL_B_INX | 3 | | | 3 (0)| 00:00:01 | 4 | 4 |
|* 7 | TABLE ACCESS BY LOCAL INDEX ROWID| TABLE1 | 2 | 72 | | 7 (0)| 00:00:01 | 4 | 4 |
Predicate Information (identified by operation id):
6 - access("T1"."COL_B"="T2"."COL_B")
7 - filter("T1"."START_DT"=TO_DATE(' 2012-06-02 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
"T1"."RECORD_TYP"="T2"."RECORD_TYP")
Statistics
105 recursive calls
0 db block gets
640720 consistent gets
363307 physical reads
635656 redo size
3896682 bytes sent via SQL*Net to client
86718 bytes received via SQL*Net from client
7854 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
117794 rows processed
SQL>TKPROF
SELECT t1.COL_A,
t1.COL_B,
t1.record_typ,
TO_date('14/06/2012','DD/MM/YYYY') ,
MIN(start_dt) AS First_Seen,
MAX(start_dt) AS Last_Seen
FROM TABLE1 t1,
TABLE2 t2
WHERE t1.start_dt = TO_date('14/06/2012','DD/MM/YYYY') - 12
AND
t1.COL_B = t2.COL_B
AND t1.record_typ = t2.record_typ
GROUP BY t1.col_a,t1.col_b,t1.record_typ,TO_date('14/06/2012','DD/MM/YYYY')
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 7853 0.15 0.28 0 0 0 117793
total 7853 0.15 0.28 0 0 0 117793
Misses in library cache during parse: 0
Parsing user id: 85 Which parameters or settings I want to check , because this query run before 4 minutes. now it takes 20 minutes... or in anyway I can rewrite this query using multiple staging table or something like that...Hi,
1) you didn't trace the session correctly -- you probably switched tracing off before the session finished fetching all rows. Do it again, and this time end tracing by exiting the session (this way you make sure that the cursor is closed and plan stats are dumped to the trace file)
2) the plan seems to be sensible -- it costs you only 600k reads to retrieve 150k rows, that's good read-to-row ratio. You can improve it if you get read of TABLE ACCESS BY ROWID operation, but that would require creating an index on all the columns that the query needs (both in WHERE clause and in column projection) which looks like a big overhead (especially given that this is a table with 3 billion records)
3) autotrace stats seem to agree with the plan -- you're making 600k gets and half of them result in single-block disk reads. Assuming 5ms per read that's close to 20 min that you are getting. Of course, 50% buffer cache ratio is far from being perfect, and better caching is most likely the reason why the query was performing better in the past. Look at the the buffer hit ratio trend for the database -- perhaps some other activity is trashing the buffer cache, resulting in performance degradation of this query as well
Best regards,
Nikolay
Maybe you are looking for
-
Selecting and moving clips to the right of the TCI
Is there a way to be able to move the editted clips that are to the right of my current TCI, and keep the edits as they are? I'm looking for a ripple delete with more control if that makes sense. My old editting software had a group tool which alowed
-
Purchased songs not showing up in account
I have music that i have purchased on a pervious device, with the same account. I have a new device and am trying to download the music on and it is not showing on the device that i have purchased this music. I have another device hooked up to the sa
-
Order confirmation USD price convert in Riyal
Dear Expert in order confirmation price are coming in dollar i want to convert this in riyal where can i multiply this in sap script and how? please its very urgent. help me. Regards ahmed
-
I recently reset an iPhone 3 for my little bro. When I tried connecting it to my windows 8 laptop, it doesn't recognize or charge it, neither does iTunes. Bit it charges on wall mount. Answers appreciated
-
?? external drives/copy large folder issue ??
Hola; I am trying to copy my large iTunes library from a 1T Seagate [desktop model]to a new 1T WD drive [portable model]. Both drives are Mac Os Extended (journaled) and verified. First: I created a new small library on the WD and used "add to librar