Help in fine tuning query
Hi all iam fairly new to oracle and trying to optimize a query which is taking more than 2 minutes to execute. Please provide me some suggestions on how to optimize this query.
select b.acct_nbr, b.REGVALUE, b.Addr1, b.Addr2, b.Addr3,
b.Addr4, b.city, b.state_id, b.zip
from FIRM f, PROD p, (select a.acct_nbr, a. REGVALUE, a.Addr1, a.Addr2, a.Addr3,
a.Addr4, a.city, a.state_id, a.zip
from ACCOUNT a
where (UPPER(A.REGVALUE) LIKE '% 3150IAC %'
or UPPER(A.REGVALUE) LIKE '% 3150 IAC %'
or UPPER(A.REGVALUE) LIKE '% 3150 (IAC) %'
or UPPER(A.REGVALUE) LIKE '% 3150_IAC %'
or UPPER(A.REGVALUE) LIKE '% 3150-IAC %'
or UPPER(A.REGVALUE) LIKE '% BOROUGH %'
or UPPER(A.REGVALUE) LIKE '% CITY %'
or UPPER(A.REGVALUE) LIKE '% CNTY %'
or UPPER(A.REGVALUE) LIKE '% COUNTY %'
or UPPER(A.REGVALUE) LIKE '% DIST %'
or UPPER(A.REGVALUE) LIKE '% DISTRICT %'
or UPPER(A.REGVALUE) LIKE '% EMPLOYEE %'
or UPPER(A.REGVALUE) LIKE '% EE %'
or UPPER(A.REGVALUE) LIKE '% LOCAL %'
or UPPER(A.REGVALUE) LIKE '% MUNICIPALITY %'
or UPPER(A.REGVALUE) LIKE '% OFFICE OF %'
or UPPER(A.REGVALUE) LIKE '% OFFICE FOR %'
or UPPER(A.REGVALUE) LIKE '% STATE %'
or UPPER(A.REGVALUE) LIKE '% TOWN %'
or UPPER(A.REGVALUE) LIKE '% TOWNSHIP %'
or UPPER(A.REGVALUE) LIKE '% UNIV %'
or UPPER(A.REGVALUE) LIKE '% UNIVERSITY %'
or UPPER(A.REGVALUE) LIKE '% WARD %')
and (UPPER(A.REGVALUE) NOT LIKE '% JTWROS %'
and UPPER(A.REGVALUE) NOT LIKE '% INC %'
and UPPER(A.REGVALUE) NOT LIKE '% LLC %'
and UPPER(A.REGVALUE) NOT LIKE '% LLP %'
and UPPER(A.REGVALUE) NOT LIKE '% TEST %'
and UPPER(A.REGVALUE) NOT LIKE '% TESTED %'
and UPPER(A.REGVALUE) NOT LIKE '% TESTCONT %'
and UPPER(A.REGVALUE) NOT LIKE '% TESTOVER %'
and UPPER(A.REGVALUE) NOT LIKE '% TESTTEE %'
and UPPER(A.REGVALUE) NOT LIKE '% TOTHCUST %'
and UPPER(A.REGVALUE) NOT LIKE '% DECEDENT %'
and UPPER(A.REGVALUE) NOT LIKE '% BOTH1 %'
and UPPER(A.REGVALUE) NOT LIKE '% BOTH2 %'
and UPPER(A.REGVALUE) NOT LIKE '% BOTH# %'
and UPPER(A.REGVALUE) NOT LIKE '% BOTHYACK %'
and UPPER(A.REGVALUE) NOT LIKE '% MYCOLLECTION %')) b
where b.tech_id = f.tech_id
and b.prod_cd = p.prod_cd
and (b.est_dt between '01-OCT-11' and '31-OCT11'
or b.closed_dt between '01-OCT-11' and '31-OCT-11')
and b.IB_cd in ('EXN', 'DTS', 'ALP')
Edited by: 903555 on Dec 21, 2011 8:45 AM
903555 wrote:
Please find the information, let me know if any thing else required.Please re-read the thread I posted because this still isn't enough information to identify the problem.
Also, please use \ tags so fixed-width fonts display correctly.
For example:
\My Explain Plan Here\would display as:My Explain Plan HereIt looks like based on the explain plan Oracle is only expecting ONE row. Is that correct? Are your statistics up-to-date?
Similar Messages
-
Few Methods of fine tuning query
I want to know few methods of fine tuning the query
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/toc.htm
-
Need help in Fine Tuning this query
Hello Gurus,
The below sql's are from Application engine . It runs more than 5 hours to complete . I have fewer knowledge on sql tuning and request to repharse the sql's to perform and complete the program within One hour.
PS_GE_GAPS_INV is going thru Range Scan and TAO table is going for Full Table Scan.
I have indexes on PS_GE_GAPS_INV which is the main table. Iam joining TAO(Temporary table) and Main Table with common keys defined thru Application designer.
Appreciate all your help.
First Sql :
UPDATE PS_GE_GAPS_INV
SET LAST_DTTM_UPDATE = TO_DATE(SYSDATE,'DD-MM-YY-HH24.MI.SS."000000"')
WHERE
(BUSINESS_UNIT,RECONCILE_DT,GE_INVENTORY_SOURC,TAG_NUMBER,ASSET_ID,SERIAL_ID_TR,S
ERIAL_ID,GE_CUSTODIAN_PHY,CUSTODIAN,DEPTID_P,DEPTID,CHARTFIELD2,CHARTFIELD3,GE_GA
P_RULE,SEQUENCENO) IN (
SELECT DISTINCT B.BUSINESS_UNIT
,B.RECONCILE_DT
,B.GE_INVENTORY_SOURC
,B.TAG_NUMBER
,B.ASSET_ID
,B.SERIAL_ID_TR
,B.SERIAL_ID
,B.GE_CUSTODIAN_PHY
,B.CUSTODIAN
,B.DEPTID_P
,B.DEPTID
,B.CHARTFIELD2
,B.CHARTFIELD3
,B.GE_GAP_RULE
,B.SEQUENCENO
FROM PS_GE_GAPS_TAO A
, PS_GE_GAPS_INV B
WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT
AND (A.RECONCILE_DT = B.RECONCILE_DT
OR (A.RECONCILE_DT IS NULL
AND B.RECONCILE_DT IS NULL))
AND A.GE_GAP_RULE = B.GE_GAP_RULE
AND A.SEQUENCENO = B.SEQUENCENO
AND A.GE_INVENTORY_SOURC = B.GE_INVENTORY_SOURC
AND A.TAG_NUMBER = B.TAG_NUMBER
AND A.ASSET_ID = B.ASSET_ID
AND A.SERIAL_ID_TR = B.SERIAL_ID_TR
AND A.SERIAL_ID = B.SERIAL_ID
AND A.GE_CUSTODIAN_PHY = B.GE_CUSTODIAN_PHY
AND A.CUSTODIAN = B.CUSTODIAN
AND A.DEPTID_P = B.DEPTID_P
AND A.DEPTID = B.DEPTID
AND A.CHARTFIELD2 = B.CHARTFIELD2
AND A.CHARTFIELD3 = B.CHARTFIELD3
AND A.BUSINESS_UNIT = %Bind(BUSINESS_UNIT)
AND A.RECONCILE_DT = %Bind(RECONCILE_DT)
AND A.PROCESS_INSTANCE =%ProcessInstance)
Second Sql :
INSERT INTO PS_GE_GAPS_INV (BUSINESS_UNIT
, RECONCILE_DT
, GE_GAP_RULE
, SEQUENCENO
, GE_INVENTORY_SOURC
, TAG_NUMBER
, ASSET_ID
, SERIAL_ID_TR
, SERIAL_ID
, GE_CUSTODIAN_PHY
, CUSTODIAN
, VENDOR_ID
, DEPTID_P
, DEPTID
, CHARTFIELD2
, CHARTFIELD3
, GE_GAP_STATUS
, CERTMESSAGE
, LAST_DTTM_UPDATE
, COMMENT1
, ASSET_STATUS
, DESCR1
, DESCR
, NAME1_AC
, NAME1
, CATEGORY_DESCR
, CATEGORY
, OPERATING_UNIT_TO
, OPERATING_UNIT
, PROJECT_ID_P
, PROJECT_ID
, PRODUCT_TO
, PRODUCT
, INV_ITEM_ID
, ITEM_FIELD_C30_B
, ITEM_FIELD_C30_C)
SELECT DISTINCT B.BUSINESS_UNIT
, B.RECONCILE_DT
, B.GE_GAP_RULE
, B.SEQUENCENO
, B.GE_INVENTORY_SOURC
, B.TAG_NUMBER
, B.ASSET_ID
, B.SERIAL_ID_TR
, B.SERIAL_ID
, B.GE_CUSTODIAN_PHY
, B.CUSTODIAN
, B.VENDOR_ID
, B.DEPTID_P
, B.DEPTID
, B.CHARTFIELD2
, B.CHARTFIELD3
, B.GE_GAP_STATUS
, B.CERTMESSAGE
, B.LAST_DTTM_UPDATE
, B.COMMENT1
, B.ASSET_STATUS
, B.DESCR1
, B.DESCR
, B.NAME1_AC
, B.NAME1
, B.CATEGORY_DESCR
, B.CATEGORY
, B.OPERATING_UNIT_TO
, B.OPERATING_UNIT
, B.PROJECT_ID_P
, B.PROJECT_ID
, B.PRODUCT_TO
, B.PRODUCT
, B.INV_ITEM_ID
, B.ITEM_FIELD_C30_B
, B.ITEM_FIELD_C30_C
FROM PS_GE_GAPS_TAO B
WHERE B.BUSINESS_UNIT = %Bind(BUSINESS_UNIT)
AND B.RECONCILE_DT =%Bind(RECONCILE_DT)
AND NOT EXISTS (
SELECT 'X'
FROM PS_GE_GAPS_INV A
WHERE B.BUSINESS_UNIT = A.BUSINESS_UNIT
AND (B.RECONCILE_DT = A.RECONCILE_DT
OR (B.RECONCILE_DT IS NULL
AND A.RECONCILE_DT IS NULL))
AND B.GE_GAP_RULE = A.GE_GAP_RULE
AND B.SEQUENCENO = A.SEQUENCENO
AND B.GE_INVENTORY_SOURC = A.GE_INVENTORY_SOURC
AND B.TAG_NUMBER = A.TAG_NUMBER
AND B.ASSET_ID = A.ASSET_ID
AND B.SERIAL_ID_TR = A.SERIAL_ID_TR
AND B.SERIAL_ID = A.SERIAL_ID
AND B.GE_CUSTODIAN_PHY = A.GE_CUSTODIAN_PHY
AND B.CUSTODIAN = A.CUSTODIAN
AND B.DEPTID_P = A.DEPTID_P
AND B.DEPTID = A.DEPTID
AND B.CHARTFIELD2 = A.CHARTFIELD2
AND B.CHARTFIELD3 = A.CHARTFIELD3)
Third Sql :
INSERT INTO PS_GE_GAPST_TAO (BUSINESS_UNIT
, RECONCILE_DT
, GE_GAP_RULE
, SEQUENCENO
, GE_INVENTORY_SOURC
, TAG_NUMBER
, ASSET_ID
, SERIAL_ID_TR
, GE_CUSTODIAN_PHY
, SERIAL_ID
, CUSTODIAN
, DEPTID_P
, DEPTID
, CHARTFIELD2
, CHARTFIELD3
, PROCESS_INSTANCE
, GE_GAP_STATUS
, CERTMESSAGE
, LAST_DTTM_UPDATE
, COMMENT1
, ASSET_STATUS
, DESCR1
, DESCR
, VENDOR_ID
, NAME1_AC
, NAME1
, CATEGORY_DESCR
, CATEGORY
, OPERATING_UNIT_TO
, OPERATING_UNIT
, PROJECT_ID_P
, PROJECT_ID
, PRODUCT_TO
, PRODUCT
, INV_ITEM_ID
, ITEM_FIELD_C30_B
, ITEM_FIELD_C30_C)
SELECT DISTINCT BUSINESS_UNIT
, RECONCILE_DT
, GE_GAP_RULE
, SEQUENCENO
, GE_INVENTORY_SOURC
, TAG_NUMBER
, ASSET_ID
, SERIAL_ID_TR
, GE_CUSTODIAN_PHY
, SERIAL_ID
, CUSTODIAN
, DEPTID_P
, DEPTID
, CHARTFIELD2
, CHARTFIELD3
, %ProcessInstance
, GE_GAP_STATUS
, CERTMESSAGE
, LAST_DTTM_UPDATE
, COMMENT1
, ASSET_STATUS
, DESCR1
, DESCR
, VENDOR_ID
, NAME1_AC
, NAME1
, CATEGORY_DESCR
, CATEGORY
, OPERATING_UNIT_TO
, OPERATING_UNIT
, PROJECT_ID_P
, PROJECT_ID
, PRODUCT_TO
, PRODUCT
, INV_ITEM_ID
, ITEM_FIELD_C30_B
, ITEM_FIELD_C30_C
FROM ps_ge_gaps_inv B
WHERE b.business_unit = %Bind(BUSINESS_UNIT)
AND b.reconcile_dt =%Bind(RECONCILE_DT)
AND NOT EXISTS (
SELECT 'X'
FROM ps_ge_gaps_tao a
WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT
AND (A.RECONCILE_DT = B.RECONCILE_DT
OR (A.RECONCILE_DT IS NULL
AND B.RECONCILE_DT IS NULL))
AND A.GE_GAP_RULE = B.GE_GAP_RULE
AND A.SEQUENCENO = B.SEQUENCENO
AND A.GE_INVENTORY_SOURC = B.GE_INVENTORY_SOURC
AND A.TAG_NUMBER = B.TAG_NUMBER
AND A.ASSET_ID = B.ASSET_ID
AND A.SERIAL_ID_TR = B.SERIAL_ID_TR
AND A.SERIAL_ID = B.SERIAL_ID
AND A.GE_CUSTODIAN_PHY = B.GE_CUSTODIAN_PHY
AND A.CUSTODIAN = B.CUSTODIAN
AND A.DEPTID_P = B.DEPTID_P
AND A.DEPTID = B.DEPTID
AND A.CHARTFIELD2 = B.CHARTFIELD2
AND A.CHARTFIELD3 = B.CHARTFIELD3 )
Best Regards,
BalaAre the statistics on your temp table up to date?. Either add an %UpdateStats SQL step after loading the temp table, or check the following notes if your database is Oracle and is a relatively current version:
pscbo_stats - Improving Statistics in Oracle RDBMS for PeopleSoft Enterprise [ID 1322888.1]
E-ORA PeopleSoft Enterprise Performance on Oracle 11g Database [ID 1460735.1]
Regards,
Bob -
Help in fine tuning this query
My query id this,
select a.event_id,a.document_id
from sample_transaction a
where exists (select 1 from sample_transaction b where b.event_id <> a.event_id and b.document_id = a.document_id );
The execution plan is like this,
SELECT STATEMENT Cost = 5596
FILTER
TABLE ACCESS FULL SAMPLE_TRANSACTION
TABLE ACCESS BY INDEX ROWID SAMPLE_TRANSACTION
INDEX RANGE SCAN I_SAMPLE_TRANSACTION_FK_EVT
There are 6 million records in the table.
How can i fine tune this query so that i get the results
Example is
my table has
EVENT_ID DOCUMENT_ID
100 200
100 200
101 201
102 201
103 203
104 203
105 204
105 204
106 106
My result should be
EVENT_ID DOCUMENT_ID
101 201
102 201
103 203
104 203
nullBased on your select statement, you will bring back every row in sample_transaction where the document is referenced by more than one event. Looking at it another way, the only rows skipped are those where the document is only used by one event.
The full table scan is not necessarilly a problem since Oracle has to check all rows. You may improve performance if you add an index on document_id. That will allow Oracle to do a better query on the EXISTS clause. Remember to rebuild your statistics after adding the index. -
Help with fine tuning my bones
I am having trouble setting up my bones on a cartoon im making. I have all of the body parts as separate movie clips, but every time I add a new bone it moves the rest of the movie clips slightly. This also happens when I try to fine tune where my bone pivot points are, or adjust where the symbol is. I move one into place and it slightly slides everything else. This is very frustrating when trying to fine tune my bone setup. Is there anything I can do about this. Am I the only one who has run into this issue?
Anyone? You can test what im talking about by making a box. Copy it 3 times upwards in a nice evenly spaced row. convert them to movie clips then use the bone tool to connect all the boxes. Watch the boxes shift as you connect them. The same shift will happen when you try and edit where the bone connects to each box.
-
SPA3102 - Some Fine Tuning Query
Hi,
My SPA3102 works fine answering PSTN and VoIP calls, including call waiting and 2-way switching and 3-way calls, caller ID pass thru, etc.
But if I have the phone "off hook" for any reason and a PSTN call comes in, (it rings on another phone directly connected to PSTN line) placing the ATA attached phone on hook does not cause phone to ring through (PSTN ring thru line 1) no matter how long I wait. So I was wondering what parameter affects this aspect as I'm sure I had this working in the past.
Oh, by way of background information, the PSTN line voltage on the status screen shows typically 49V on hook, 7V off hook and -49V when PSTN is ringing (UK BT line).
Any comment most welcome - Cheers from MikeI believe this is a normal behavior according to the admin guide:
If Line 1 is busy (fxs port is off-hook) when the PSTN line rings, the SPA will not attempt to ring through, even if Line 1 later becomes idle (putting fxs port on-hook) while the PSTN is still ringing. -
Help with fine tuning specification.
I must stress I'm considering this upgrade not because I have a proven need for a newer, faster machine but because I'd like to keep up to date (Snow Leopard) and because I'm in the fortunate position of being able to afford it!
I'm not into video processing, 3D animation or even much photo work (in Aperture) - most of my use being text or web based so I understand that any Mac Pro will be more than up to the tasks I ask of it. But…
1) Given my "light" use by professional standards, would I notice any real difference by paying the not inconsiderable premium for the 8 core or could the 4 core actually seem faster?
2) If 4 core, would the upgrade to 2.93GHz be noticeable (or worth the money!)
3) Assuming I go 4 core, am I right in thinking that if I buy the standard 3GB memory, then to buy say 4GB from Crucial (at £77) I'd have to remove one 1GB as supplied so end up with 6GB - i.e. only marginally more than the 6GB option from Apple?
4) Would I notice improved graphics on my 30" by going for the 4870 instead of the standard card?
Thanks for any input.The GT120 handles 2D just fine, so no need for the ATI unless it just does more in Snow Leopard.
4-core is fine. Really. I have Core i7 920s and they fly at web, Office, all the basics and then some.
Memory is triple channel, or dual channel. So while it may be possible to boot with 1 DIMM, it should be in two sets of two, or a set of three. In your shoes, I'd get 3 x 2GB from Apple and be done with it, same cost as buying and upgrading.
4GB may require 3 x 4GB or 4 x 4GB as mixing two 4GB and two 1GB may not work.
http://www.macsales.com/memory/ - look for Mac Pro 2009 (DDR3 ECC).
Do you game? 3D? plan or might install Windows? GT and ATI don't get along. And there is the Nvidia GTX 285 ($419-449) out there. For Windows, I prefer Nvidia, though ATI has had the better drivers in Mac OS so far.
One person bought the 2.66 and then dropped in retail 3.3GHz Nehalem part - they never even used the 2.66 (sold but kept until they stress tested the system).
You'll fall in love with it and Snow Leopard / Windows 7 with the memory and system bandwidth. -
Hi,
I need some help in performing tuning of a big query. Explain plan is as under:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
Edited by: AbdulHadi on Sep 16, 2011 3:56 PM
Edited by: AHadi on Sep 19, 2011 10:02 AM3 SORT GROUP BY 47916 25M 491G 15M (3) 17:30:31
4 VIEW 870M 445G 15M (2) 17:24:08
5 HASH GROUP BY 870M 427G 885G 15M (2) 17:24:08
In above steps its using very high temporary tablespace usage. please try to tune your query.
- dynamic sampling used for this statement
The statistics appears to be stale. -
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)] -
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,
I want to know about fine tuning a report. One way, I know is to break the query which extracts data from different tables separately and finally joining it using FOR ALL ENTRIES. What are the different methods to fine tune a report.
Please reply with suitabe answers.Hi
see this
1) Dont use nested select statements
2) If possible use for all entries in addition
3) In the where addition make sure you give all the primary key
4) Use Index for the selection criteria.
5) You can also use inner joins
6) You can try to put the data from the first select statement into an Itab and then in order to select the data from the second table use for all entries in.
7) Use the runtime analysis SE30 and SQL Trace (ST05) to identify the performance and also to identify where the load is heavy, so that you can change the code accordingly
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5d0db4c9-0e01-0010-b68f-9b1408d5f234
ABAP performance depends upon various factors and in devicded in three parts:
1. Database
2. ABAP
3. System
Run Any program using SE30 (performance analys) to improve performance refer to tips and trics section of SE30, Always remember that ABAP perfirmance is improved when there is least load on Database.
u can get an interactive grap in SE30 regarding this with a file.
also if u find runtime of parts of codes then use :
Switch on RTA Dynamically within ABAP Code
*To turn runtim analysis on within ABAP code insert the following code
SET RUN TIME ANALYZER ON.
*To turn runtim analysis off within ABAP code insert the following code
SET RUN TIME ANALYZER OFF.
Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
Avoid for all entries in JOINS
Try to avoid joins and use FOR ALL ENTRIES.
Try to restrict the joins to 1 level only ie only for tables
Avoid using Select *.
Avoid having multiple Selects from the same table in the same object.
Try to minimize the number of variables to save memory.
The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
Avoid creation of index as far as possible
Avoid operators like <>, > , < & like % in where clause conditions
Avoid select/select single statements in loops.
Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
Avoid using ORDER BY in selects
Avoid Nested Selects
Avoid Nested Loops of Internal Tables
Try to use FIELD SYMBOLS.
Try to avoid into Corresponding Fields of
Avoid using Select Distinct, Use DELETE ADJACENT
Check the following Links
Re: performance tuning
Re: Performance tuning of program
http://www.sapgenie.com/abap/performance.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
check the below link
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
See the following link if it's any help:
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
Check also http://service.sap.com/performance
and
books like
http://www.sap-press.com/product.cfm?account=&product=H951
http://www.sap-press.com/product.cfm?account=&product=H973
http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
Performance tuning for Data Selection Statement
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
Debugger
http://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
http://www.cba.nau.edu/haney-j/CIS497/Assignments/Debugging.doc
http://help.sap.com/saphelp_erp2005/helpdata/en/b3/d322540c3beb4ba53795784eebb680/frameset.htm
Run Time Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
SQL trace
http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
CATT - Computer Aided Testing Too
http://help.sap.com/saphelp_47x200/helpdata/en/b3/410b37233f7c6fe10000009b38f936/frameset.htm
Test Workbench
http://help.sap.com/saphelp_47x200/helpdata/en/a8/157235d0fa8742e10000009b38f889/frameset.htm
Coverage Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c7/af9a79061a11d4b3d4080009b43351/content.htm
Runtime Monitor
http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
Memory Inspector
http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
ECATT - Extended Computer Aided testing tool.
http://help.sap.com/saphelp_47x200/helpdata/en/20/e81c3b84e65e7be10000000a11402f/frameset.htm
Just refer to these links...
performance
Performance
Performance Guide
performance issues...
Performance Tuning
Performance issues
performance tuning
performance tuning
You can go to the transaction SE30 to have the runtime analysis of your program.Also try the transaction SCI , which is SAP Code Inspector.
1 Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
2 Avoid for all entries in JOINS
3 Try to avoid joins and use FOR ALL ENTRIES.
4 Try to restrict the joins to 1 level only ie only for 2 tables
5 Avoid using Select *.
6 Avoid having multiple Selects from the same table in the same object.
7 Try to minimize the number of variables to save memory.
8 The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
9 Avoid creation of index as far as possible
10 Avoid operators like <>, > , < & like % in where clause conditions
11 Avoid select/select single statements in loops.
12 Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
13 Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
14 Avoid using ORDER BY in selects
15 Avoid Nested Selects
16 Avoid Nested Loops of Internal Tables
17 Try to use FIELD SYMBOLS.
18 Try to avoid into Corresponding Fields of
19 Avoid using Select Distinct, Use DELETE ADJACENT.
<b>Reward points for useful Answers</b>
Regards
Anji -
help needed for writing query
i have the following tables(with data) as mentioned below
FK*-foregin key (SUBJECTS)
FK**-foregin key (COMBINATION)
1)SUBJECTS(table name)
SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
2 02 Computer Science
3 03 Physics
4 04 Chemistry
5 05 Mathematics
7 07 Commerce
8 08 Computer Applications
9 09 Biology
2)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
383 S1 9 4 2 3
384 S2 4 2 5 3
---------I actually designed the ABOVE table also like this
3) a)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
383 S1
384 S2
b)COMBINATION_DET
COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
1 383 9
2 383 4
3 383 2
4 383 3
5 384 4
6 384 2
7 384 5
8 384 3
Business rule: a combination consists of a maximum of 4 subjects (must contain)
and the user is less relevant to a COMB_NAME(name of combinations) but user need
the subjects contained in combinations
i need the following output
COMB_ID COMB_NAME SUBJECT1 SUBJECT2 SUBJECT3 SUBJECT4
383 S1 Biology Chemistry Computer Science Physics
384 S2 Chemistry Computer Science Mathematics Physics
or even this is enough(what i actually needed)
COMB_ID subjects
383 Biology,Chemistry,Computer Science,Physics
384 Chemistry,Computer Science,Mathematics,Physics
you can use any of the COMBINATION table(either (2) or (3))
and i want to know
1)which design is good in this case
(i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
good method to link with same table but if 4 subjects only(and must) comes
detail table is not neccessary )
now i am achieving the result by program-coding in C# after getting the rows from oracle
i am using oracle 9i (also ODP.NET)
i want to know how can i get the result in the stored procedure itsef.
2)how it could be designed in any other way.
any help/suggestion is welcome
thanks for your time --PradeeshWell I forgot the table-alias, here now with:
SELECT C.COMB_ID
, C.COMB_NAME
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
FROM COMBINATION C;
As you need exactly 4 subjects, the columns-solution is just fine I would say. -
SQL is behaving different for different inputs. Its taking 20mins to execute when oraganization_id=382 is passed adn with other organization_id's are passed it is taking less than 2 minutes. Execution plan is different in both the cases. I will provide bith sql and execution plans.
I tried rebuilding the indexes and gather stats for the tables but it did not help out.
Please help me in tuning the sql.
1) SQL
SELECT DISTINCT mp . organization_name , mp . organization_code , mp .
organization_name , wpsv . pick_slip_number , wpsv .
from
subinventory , csu . location shipto_location , wpsv . from_locator_id ,
wpsv . to_subinventory , wpsv . to_locator_id , mtrh . request_number
mo_number , wpsv . detailing_date , mtrl . line_id mo_line_id , wpsv .
transaction_id , wdd . move_order_line_id , to_char ( wdd .
source_header_id ) order_n_header_char , to_char ( wdd . source_line_id )
order_n_line_char , wdd . source_header_id , wdd . source_line_id , mtrl .
line_number mo_line_number , wtr . trip_id , wtr . name rip_name , wnd .
delivery_id , wnd . name delivery_name , wdd . shipping_instructions , wdd
. packing_instructions , r . customer_name , wdd . source_header_number ,
ol . line_number sales_line_number , ol . schedule_ship_date , sum ( NVL (
wdd . requested_quantity , 0 ) ) requested_quantity , sum ( NVL ( wdd .
requested_quantity2 , 0 ) ) requested_quantity2 , sum ( NVL ( wdd .
shipped_quantity , 0 ) ) shipped_quantity , sum ( NVL ( wdd .
shipped_quantity2 , 0 ) ) shipped_quantity2 , wdd . ship_tolerance_above ,
wdd . ship_tolerance_below , msi.description item_info , msi . segment1 ,
msi . description item_description , wdd . inventory_item_id , os .
set_name , wdd . requested_quantity_uom , wdd . requested_quantity_uom2 ,
wpsv . transaction_id , wpsv . line_status , wdd . revision , wpsv .
primary_qty , wpsv . trans_um1 , wpsv . secondary_qty , wpsv . trans_um2 ,
wpsv . qc_grade , wpsv . lot_id , wpsv . lot_no lot_number , iim .
attribute19 min_max_stor_temp , wpsv . location , SUBSTR ( wpsv . location ,
1 , 3 ) lot_location_group FROM IC_ITEM_MST_B iim , WSH_TRIPS wtr ,
WSH_TRIP_STOPS wts , WSH_DELIVERY_LEGS wlg , WSH_NEW_DELIVERIES wnd ,
WSH_DELIVERY_ASSIGNMENTS wda , WSH_DELIVERY_DETAILS wdd ,
GMI_WSH_PICK_SLIP_V wpsv , OE_ORDER_LINES_ALL ol , OE_SETS os ,
RA_CUSTOMERS r , IC_TXN_REQUEST_HEADERS mtrh , IC_TXN_REQUEST_LINES mtrl ,
MTL_SYSTEM_ITEMS msi , HZ_CUST_SITE_USES_ALL csu , OE_ORDER_HEADERS_ALL ooh
, ( SELECT mp . organization_id , mp . organization_code , hou . name
organization_name FROM HR_ORGANIZATION_UNITS hou , MTL_PARAMETERS mp where
mp . organization_id = hou . organization_id ) mp WHERE wtr.trip_id (+) =
wts.trip_id AND wts.stop_id (+) = wlg.pick_up_stop_id AND wlg.delivery_id
(+) = wnd.delivery_id AND wnd.delivery_id (+) = wda.delivery_id AND
wdd.source_header_id = ooh.header_id AND csu.site_use_id =
ooh.ship_to_org_id AND os.set_id (+) = wdd.ship_set_id AND
wda.delivery_detail_id = wdd.delivery_detail_id AND ol.line_id =
wdd.source_line_id AND wpsv.transaction_id = ol.line_id AND
wpsv.transaction_id = wdd.source_line_id AND r.customer_id =
wdd.customer_id AND mtrl.header_id = mtrh.header_id AND mtrl.line_id =
wdd.move_order_line_id AND mtrl.inventory_item_id = wpsv.inventory_item_id
AND mtrl.line_id = wpsv.move_order_line_id AND msi.inventory_item_id =
wdd.inventory_item_id AND msi.organization_id = mtrl.organization_id AND
iim.item_no = msi.segment1 AND mtrl.organization_id = : p_organization_id
AND mtrl.organization_id = mp.organization_id and mtrh.request_number
between : p_move_order_low and : p_move_order_high and wpsv.line_status =
'UNPICKED' GROUP BY mp.organization_name , mp.organization_code ,
csu.location , wpsv.pick_slip_number , wpsv.from_subinventory ,
wpsv.from_locator_id , wpsv.to_subinventory , wpsv.to_locator_id ,
mtrh.request_number , wpsv.detailing_date , mtrl.line_id ,
wpsv.transaction_id , wdd.move_order_line_id , to_char (
wdd.source_header_id ) , to_char ( wdd.source_line_id ) ,
wdd.source_header_id , wdd.source_line_id , mtrl.line_number , wtr.trip_id ,
wtr.name , wnd.delivery_id , wnd.name , wdd.shipping_instructions ,
wdd.packing_instructions , r.customer_name , wdd.source_header_number ,
ol.line_number , ol.schedule_ship_date , wdd.ship_tolerance_above ,
wdd.ship_tolerance_below , msi.description , msi.segment1 , msi.description
, wdd.inventory_item_id , os.set_name , wdd.requested_quantity_uom ,
wdd.requested_quantity_uom2 , wpsv.transaction_id , wpsv.line_status ,
wdd.revision , wpsv.primary_qty , wpsv.trans_um1 , wpsv.secondary_qty ,
wpsv.trans_um2 , wpsv.qc_grade , wpsv.lot_id , wpsv.lot_no ,
iim.attribute19 , wpsv.location , SUBSTR ( wpsv.location , 1 , 3 ) ORDER BY
1 ASC,2 ASC,10 ASC,6 ASC,4 ASC,17 ASC,5 ASC,7 ASC,8 ASC,9 ASC,13 ASC,12 ASC,
55 ASC,43 ASC,14 ASC,19 ASC,18 ASC,39 ASC,53 ASC,29 ASC,36 ASC,37 ASC,38
ASC,30 ASC,41 ASC,31 ASC,42 ASC,40 ASC,33 ASC,34 ASC,35 ASC,27 ASC,28 ASC,
20 ASC,21 ASC,22 ASC,23 ASC,26 ASC,24 ASC,25 ASC , mp.organization_code ,
mo_number , pick_slip_number , mo_line_number , item_info
2) Explain plan when the query is taking less than a minute
Rows Row Source Operation
1 SORT UNIQUE (cr=1299 r=87 w=0 time=50693 us)
1 SORT GROUP BY (cr=1299 r=87 w=0 time=50475 us)
1 FILTER (cr=1299 r=87 w=0 time=50009 us)
1 NESTED LOOPS (cr=1299 r=87 w=0 time=50002 us)
1 NESTED LOOPS (cr=1296 r=87 w=0 time=49937 us)
1 NESTED LOOPS (cr=1293 r=87 w=0 time=49873 us)
1 NESTED LOOPS (cr=1290 r=87 w=0 time=49799 us)
1 NESTED LOOPS (cr=1287 r=87 w=0 time=49740 us)
1 NESTED LOOPS OUTER (cr=1284 r=87 w=0 time=49676 us)
1 NESTED LOOPS OUTER (cr=1284 r=87 w=0 time=49654 us)
1 NESTED LOOPS OUTER (cr=1284 r=87 w=0 time=49633 us)
1 NESTED LOOPS OUTER (cr=1282 r=87 w=0 time=49566 us)
1 NESTED LOOPS (cr=1279 r=87 w=0 time=49490 us)
1 NESTED LOOPS (cr=1276 r=87 w=0 time=49381 us)
1 NESTED LOOPS (cr=1273 r=87 w=0 time=49287 us)
1 NESTED LOOPS OUTER (cr=1270 r=87 w=0 time=49209 us)
1 NESTED LOOPS (cr=1270 r=87 w=0 time=49182 us)
1 NESTED LOOPS (cr=1267 r=87 w=0 time=49043 us)
1 NESTED LOOPS (cr=19 r=0 w=0 time=4308 us)
1 NESTED LOOPS (cr=16 r=0 w=0 time=4207 us)
1 NESTED LOOPS (cr=13 r=0 w=0 time=4076 us)
1 NESTED LOOPS (cr=5 r=0 w=0 time=781 us)
1 TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 r=0 w=0 time=111 us)
1 INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 r=0 w=0 time=60 us)(object id 37657)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS_TL (cr=3 r=0 w=0 time=636 us)
1 INDEX UNIQUE SCAN HR_ALL_ORGANIZATION_UNTS_TL_PK (cr=2 r=0 w=0 time=605 us)(object id 44637)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS (cr=8 r=0 w=0 time=3278 us)
1 INDEX UNIQUE SCAN HR_ORGANIZATION_UNITS_PK (cr=1 r=0 w=0 time=31 us)(object id 43498)
1 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_HEADERS (cr=3 r=0 w=0 time=104 us)
1 INDEX RANGE SCAN IC_TXN_REQUEST_HEADERS_U1 (cr=2 r=0 w=0 time=67 us)(object id 637615)
1 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=3 r=0 w=0 time=84 us)
1 INDEX RANGE SCAN IC_TXN_REQUEST_LINES_U1 (cr=2 r=0 w=0 time=53 us)(object id 637626)
1 VIEW (cr=1248 r=87 w=0 time=44702 us)
1 UNION-ALL PARTITION (cr=1248 r=87 w=0 time=44669 us)
1 NESTED LOOPS (cr=1248 r=87 w=0 time=44561 us)
1 NESTED LOOPS (cr=1244 r=87 w=0 time=44429 us)
1 NESTED LOOPS (cr=13 r=0 w=0 time=322 us)
1 NESTED LOOPS (cr=11 r=0 w=0 time=281 us)
1 NESTED LOOPS (cr=9 r=0 w=0 time=228 us)
1 NESTED LOOPS (cr=6 r=0 w=0 time=156 us)
1 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=3 r=0 w=0 time=64 us)
1 INDEX UNIQUE SCAN IC_TXN_REQUEST_LINES_PK (cr=2 r=0 w=0 time=38 us)(object id 637620)
1 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=3 r=0 w=0 time=74 us)
1 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=2 r=0 w=0 time=41 us)(object id 38017)
1 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=3 r=0 w=0 time=60 us)
1 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=2 r=0 w=0 time=38 us)(object id 637202)
1 INDEX UNIQUE SCAN IC_ITEM_MST_TL_PK (cr=2 r=0 w=0 time=33 us)(object id 637049)
1 INDEX UNIQUE SCAN IC_TXN_REQUEST_HEADERS_PK (cr=2 r=0 w=0 time=33 us)(object id 637610)
1 TABLE ACCESS BY INDEX ROWID IC_TRAN_PND (cr=1231 r=87 w=0 time=44078 us)
1907 INDEX RANGE SCAN IC_TRAN_PNDI6 (cr=10 r=0 w=0 time=3000 us)(object id 222381)
1 TABLE ACCESS BY INDEX ROWID IC_LOTS_MST (cr=4 r=0 w=0 time=90 us)
1 INDEX UNIQUE SCAN IC_LOTS_MST_PK (cr=3 r=0 w=0 time=60 us)(object id 637681)
0 FILTER (cr=0 r=0 w=0 time=2 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_TXN_REQUEST_LINES_PK (cr=0 r=0 w=0 time=0 us)(object id 637620)
0 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=0 r=0 w=0 time=0 us)(object id 38017)
0 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=0 r=0 w=0 time=0 us)(object id 637202)
0 INDEX UNIQUE SCAN IC_TXN_REQUEST_HEADERS_PK (cr=0 r=0 w=0 time=0 us)(object id 637610)
0 TABLE ACCESS BY INDEX ROWID IC_TRAN_PND (cr=0 r=0 w=0 time=0 us)
0 INDEX RANGE SCAN IC_TRAN_PNDI6 (cr=0 r=0 w=0 time=0 us)(object id 222381)
0 TABLE ACCESS BY INDEX ROWID IC_LOTS_MST (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_LOTS_MST_PK (cr=0 r=0 w=0 time=0 us)(object id 637681)
1 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_DETAILS (cr=3 r=0 w=0 time=106 us)
1 INDEX RANGE SCAN WSH_DELIVERY_DETAILS_N3 (cr=2 r=0 w=0 time=65 us)(object id 46264)
0 TABLE ACCESS BY INDEX ROWID OE_SETS (cr=0 r=0 w=0 time=3 us)
0 INDEX UNIQUE SCAN OE_SETS_U1 (cr=0 r=0 w=0 time=1 us)(object id 43138)
1 TABLE ACCESS BY INDEX ROWID OE_ORDER_LINES_ALL (cr=3 r=0 w=0 time=58 us)
1 INDEX UNIQUE SCAN OE_ORDER_LINES_U1 (cr=2 r=0 w=0 time=35 us)(object id 42102)
1 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=3 r=0 w=0 time=67 us)
1 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=2 r=0 w=0 time=41 us)(object id 38017)
1 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_ASSIGNMENTS (cr=3 r=0 w=0 time=87 us)
1 INDEX RANGE SCAN WSH_DELIVERY_ASSIGNMENTS_N3 (cr=2 r=0 w=0 time=65 us)(object id 46295)
1 TABLE ACCESS BY INDEX ROWID WSH_NEW_DELIVERIES (cr=3 r=0 w=0 time=49____
1 INDEX UNIQUE SCAN WSH_NEW_DELIVERIES_U1 (cr=2 r=0 w=0 time=28 us)(object id 46306)
0 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_LEGS (cr=2 r=0 w=0 time=37 us)
0 INDEX RANGE SCAN WSH_DELIVERY_LEGS_N1 (cr=2 r=0 w=0 time=35 us)(object id 46235)
0 TABLE ACCESS BY INDEX ROWID WSH_TRIP_STOPS (cr=0 r=0 w=0 time=3 us)
0 INDEX UNIQUE SCAN WSH_TRIP_STOPS_U1 (cr=0 r=0 w=0 time=1 us)(object id 46088)
0 TABLE ACCESS BY INDEX ROWID WSH_TRIPS (cr=0 r=0 w=0 time=2 us)
0 INDEX UNIQUE SCAN WSH_TRIPS_U1 (cr=0 r=0 w=0 time=1 us)(object id 46057)
1 TABLE ACCESS BY INDEX ROWID OE_ORDER_HEADERS_ALL (cr=3 r=0 w=0 time=47 us)
1 INDEX UNIQUE SCAN OE_ORDER_HEADERS_U1 (cr=2 r=0 w=0 time=27 us)(object id 41952)
1 TABLE ACCESS BY INDEX ROWID HZ_CUST_SITE_USES_ALL (cr=3 r=0 w=0 time=44 us)
1 INDEX UNIQUE SCAN HZ_CUST_SITE_USES_U1 (cr=2 r=0 w=0 time=29 us)(object id 236588)
1 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=3 r=0 w=0 time=52 us)
1 INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=2 r=0 w=0 time=34 us)(object id 81600)
1 TABLE ACCESS BY INDEX ROWID HZ_PARTIES (cr=3 r=0 w=0 time=46 us)
1 INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=2 r=0 w=0 time=28 us)(object id 237346)
1 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=3 r=0 w=0 time=41 us)
1 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=2 r=0 w=0 time=24 us)(object id 637202)
3) Explain plan when the query is taking 22mins (for org_id=382)
Rows Row Source Operation
1 SORT UNIQUE (cr=72660499 r=624 w=0 time=1327230739 us)
1 SORT GROUP BY (cr=72660499 r=624 w=0 time=1327230336 us)
1 FILTER (cr=72660499 r=624 w=0 time=1327229578 us)
1 NESTED LOOPS (cr=72660499 r=624 w=0 time=1327229570 us)
1 NESTED LOOPS (cr=72660496 r=623 w=0 time=1327217298 us)
1 NESTED LOOPS (cr=72660493 r=623 w=0 time=1327217219 us)
1 NESTED LOOPS OUTER (cr=72660490 r=623 w=0 time=1327217140 us)
1 NESTED LOOPS OUTER (cr=72660490 r=623 w=0 time=1327217118 us)
1 NESTED LOOPS OUTER (cr=72660490 r=623 w=0 time=1327217092 us)
1 NESTED LOOPS OUTER (cr=72660488 r=623 w=0 time=1327217006 us)
1 NESTED LOOPS (cr=72660485 r=622 w=0 time=1327207555 us)
1 NESTED LOOPS (cr=72660480 r=621 w=0 time=1327207177 us)
1 NESTED LOOPS (cr=72660477 r=621 w=0 time=1327207115 us)
1 NESTED LOOPS (cr=72660474 r=621 w=0 time=1327207034 us)
1 NESTED LOOPS (cr=72660471 r=621 w=0 time=1327206951 us)
7 NESTED LOOPS (cr=72660455 r=619 w=0 time=1327206132 us)
7 NESTED LOOPS OUTER (cr=72660439 r=613 w=0 time=1327203302 us)
7 NESTED LOOPS (cr=72660439 r=613 w=0 time=1327203073 us)
14 NESTED LOOPS (cr=72660407 r=610 w=0 time=1327200108 us)
90549 NESTED LOOPS (cr=3359 r=455 w=0 time=1818230 us)
1 NESTED LOOPS (cr=13 r=0 w=0 time=4463 us)
1 NESTED LOOPS (cr=5 r=0 w=0 time=962 us)
1 TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 r=0 w=0 time=107 us)
1 INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 r=0 w=0 time=55 us)(object id 37657)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS_TL (cr=3 r=0 w=0 time=820 us)
1 INDEX UNIQUE SCAN HR_ALL_ORGANIZATION_UNTS_TL_PK (cr=2 r=0 w=0 time=786 us)(object id 44637)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS (cr=8 r=0 w=0 time=3479 us)
1 INDEX UNIQUE SCAN HR_ORGANIZATION_UNITS_PK (cr=1 r=0 w=0 time=23 us)(object id 43498)
90549 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=3346 r=455 w=0 time=1704106 us)
90549 INDEX RANGE SCAN IC_TXN_REQUEST_LINES_N1 (cr=210 r=41 w=0 time=694480 us)(object id 133389)
14 VIEW (cr=72657048 r=155 w=0 time=1324006502 us)
14 UNION-ALL PARTITION (cr=72657048 r=155 w=0 time=1322889352 us)
14 NESTED LOOPS (cr=72657048 r=155 w=0 time=1318179989 us)
14 NESTED LOOPS (cr=72656992 r=151 w=0 time=1318005647 us)
90549 NESTED LOOPS (cr=1177138 r=52 w=0 time=20959096 us)
90549 NESTED LOOPS (cr=996040 r=51 w=0 time=18410001 us)
90549 NESTED LOOPS (cr=814942 r=51 w=0 time=15523206 us)
90549 NESTED LOOPS (cr=543294 r=50 w=0 time=10944790 us)
90549 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=271647 r=1 w=0 time=5063466 us)
90549 INDEX UNIQUE SCAN IC_TXN_REQUEST_LINES_PK (cr=181098 r=1 w=0 time=2863447 us)(object id 637620)
90549 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=271647 r=49 w=0 time=4794430 us)
90549 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=181098 r=1 w=0 time=2553802 us)(object id 38017)
90549 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=271648 r=1 w=0 time=3786267 us)
90549 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=181098 r=0 w=0 time=2164425 us)(object id 637202)
90549 INDEX UNIQUE SCAN IC_ITEM_MST_TL_PK (cr=181098 r=0 w=0 time=2260794 us)(object id 637049)
90549 INDEX UNIQUE SCAN IC_TXN_REQUEST_HEADERS_PK (cr=181098 r=1 w=0 time=1902881 us)(object id 637610)
14 TABLE ACCESS BY INDEX ROWID IC_TRAN_PND (cr=71479854 r=99 w=0 time=1295671259 us)
101213210 INDEX RANGE SCAN IC_TRAN_PNDI6 (cr=676173 r=21 w=0 time=136382307 us)(object id 222381)
14 TABLE ACCESS BY INDEX ROWID IC_LOTS_MST (cr=56 r=4 w=0 time=2052 us)
14 INDEX UNIQUE SCAN IC_LOTS_MST_PK (cr=42 r=2 w=0 time=1265 us)(object id 637681)
0 FILTER (cr=0 r=0 w=0 time=59787 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_TXN_REQUEST_LINES_PK (cr=0 r=0 w=0 time=0 us)(object id 637620)
0 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=0 r=0 w=0 time=0 us)(object id 38017)
0 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=0 r=0 w=0 time=0 us)(object id 637202)
0 INDEX UNIQUE SCAN IC_TXN_REQUEST_HEADERS_PK (cr=0 r=0 w=0 time=0 us)(object id 637610)
0 TABLE ACCESS BY INDEX ROWID IC_TRAN_PND (cr=0 r=0 w=0 time=0 us)
0 INDEX RANGE SCAN IC_TRAN_PNDI6 (cr=0 r=0 w=0 time=0 us)(object id 222381)
0 TABLE ACCESS BY INDEX ROWID IC_LOTS_MST (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_LOTS_MST_PK (cr=0 r=0 w=0 time=0 us)(object id 637681)
7 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_DETAILS (cr=32 r=3 w=0 time=2586 us)
14 INDEX RANGE SCAN WSH_DELIVERY_DETAILS_N3 (cr=16 r=1 w=0 time=1221 us)(object id 46264)
0 TABLE ACCESS BY INDEX ROWID OE_SETS (cr=0 r=0 w=0 time=32 us)
0 INDEX UNIQUE SCAN OE_SETS_U1 (cr=0 r=0 w=0 time=6 us)(object id 43138)
7 TABLE ACCESS BY INDEX ROWID OE_ORDER_LINES_ALL (cr=16 r=6 w=0 time=2715 us)
7 INDEX UNIQUE SCAN OE_ORDER_LINES_U1 (cr=9 r=2 w=0 time=1399 us)(object id 42102)
1 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_HEADERS (cr=16 r=2 w=0 time=679 us)
7 INDEX UNIQUE SCAN IC_TXN_REQUEST_HEADERS_PK (cr=9 r=0 w=0 time=124 us)(object id 637610)
1 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=3 r=0 w=0 time=50 us)
1 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=2 r=0 w=0 time=23 us)(object id 38017)
1 TABLE ACCESS BY INDEX ROWID OE_ORDER_HEADERS_ALL (cr=3 r=0 w=0 time=58 us)
1 INDEX UNIQUE SCAN OE_ORDER_HEADERS_U1 (cr=2 r=0 w=0 time=36 us)(object id 41952)
1 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=3 r=0 w=0 time=33 us)
1 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=2 r=0 w=0 time=14 us)(object id 637202)
1 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_ASSIGNMENTS (cr=5 r=1 w=0 time=358 us)
1 INDEX RANGE SCAN WSH_DELIVERY_ASSIGNMENTS_N3 (cr=2 r=0 w=0 time=68 us)(object id 46295)
1 TABLE ACCESS BY INDEX ROWID WSH_NEW_DELIVERIES (cr=3 r=1 w=0 time=9428 us)
1 INDEX UNIQUE SCAN WSH_NEW_DELIVERIES_U1 (cr=2 r=1 w=0 time=9405 us)(object id 46306)
0 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_LEGS (cr=2 r=0 w=0 time=58 us)
0 INDEX RANGE SCAN WSH_DELIVERY_LEGS_N1 (cr=2 r=0 w=0 time=55 us)(object id 46235)
0 TABLE ACCESS BY INDEX ROWID WSH_TRIP_STOPS (cr=0 r=0 w=0 time=2 us)
0 INDEX UNIQUE SCAN WSH_TRIP_STOPS_U1 (cr=0 r=0 w=0 time=1 us)(object id 46088)
0 TABLE ACCESS BY INDEX ROWID WSH_TRIPS (cr=0 r=0 w=0 time=1 us)
0 INDEX UNIQUE SCAN WSH_TRIPS_U1 (cr=0 r=0 w=0 time=1 us)(object id 46057)
1 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=3 r=0 w=0 time=55 us)
1 INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=2 r=0 w=0 time=34 us)(object id 81600)
1 TABLE ACCESS BY INDEX ROWID HZ_PARTIES (cr=3 r=0 w=0 time=48 us)
1 INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=2 r=0 w=0 time=26 us)(object id 237346)
1 TABLE ACCESS BY INDEX ROWID HZ_CUST_SITE_USES_ALL (cr=3 r=1 w=0 time=12241 us)
1 INDEX UNIQUE SCAN HZ_CUST_SITE_USES_U1 (cr=2 r=1 w=0 time=12187 us)(object id 236588)SQL is behaving different for different inputs. Its taking 20mins to execute when oraganization_id=382 is passed adn with other organization_id's are passed it is taking less than 2 minutes. Execution plan is different in both the cases. I will provide bith sql and execution plans.
I tried rebuilding the indexes and gather stats for the tables but it did not help out.
Please help me in tuning the sql.
1) SQL
SELECT DISTINCT mp . organization_name , mp . organization_code , mp .
organization_name , wpsv . pick_slip_number , wpsv .
from
subinventory , csu . location shipto_location , wpsv . from_locator_id ,
wpsv . to_subinventory , wpsv . to_locator_id , mtrh . request_number
mo_number , wpsv . detailing_date , mtrl . line_id mo_line_id , wpsv .
transaction_id , wdd . move_order_line_id , to_char ( wdd .
source_header_id ) order_n_header_char , to_char ( wdd . source_line_id )
order_n_line_char , wdd . source_header_id , wdd . source_line_id , mtrl .
line_number mo_line_number , wtr . trip_id , wtr . name rip_name , wnd .
delivery_id , wnd . name delivery_name , wdd . shipping_instructions , wdd
. packing_instructions , r . customer_name , wdd . source_header_number ,
ol . line_number sales_line_number , ol . schedule_ship_date , sum ( NVL (
wdd . requested_quantity , 0 ) ) requested_quantity , sum ( NVL ( wdd .
requested_quantity2 , 0 ) ) requested_quantity2 , sum ( NVL ( wdd .
shipped_quantity , 0 ) ) shipped_quantity , sum ( NVL ( wdd .
shipped_quantity2 , 0 ) ) shipped_quantity2 , wdd . ship_tolerance_above ,
wdd . ship_tolerance_below , msi.description item_info , msi . segment1 ,
msi . description item_description , wdd . inventory_item_id , os .
set_name , wdd . requested_quantity_uom , wdd . requested_quantity_uom2 ,
wpsv . transaction_id , wpsv . line_status , wdd . revision , wpsv .
primary_qty , wpsv . trans_um1 , wpsv . secondary_qty , wpsv . trans_um2 ,
wpsv . qc_grade , wpsv . lot_id , wpsv . lot_no lot_number , iim .
attribute19 min_max_stor_temp , wpsv . location , SUBSTR ( wpsv . location ,
1 , 3 ) lot_location_group FROM IC_ITEM_MST_B iim , WSH_TRIPS wtr ,
WSH_TRIP_STOPS wts , WSH_DELIVERY_LEGS wlg , WSH_NEW_DELIVERIES wnd ,
WSH_DELIVERY_ASSIGNMENTS wda , WSH_DELIVERY_DETAILS wdd ,
GMI_WSH_PICK_SLIP_V wpsv , OE_ORDER_LINES_ALL ol , OE_SETS os ,
RA_CUSTOMERS r , IC_TXN_REQUEST_HEADERS mtrh , IC_TXN_REQUEST_LINES mtrl ,
MTL_SYSTEM_ITEMS msi , HZ_CUST_SITE_USES_ALL csu , OE_ORDER_HEADERS_ALL ooh
, ( SELECT mp . organization_id , mp . organization_code , hou . name
organization_name FROM HR_ORGANIZATION_UNITS hou , MTL_PARAMETERS mp where
mp . organization_id = hou . organization_id ) mp WHERE wtr.trip_id (+) =
wts.trip_id AND wts.stop_id (+) = wlg.pick_up_stop_id AND wlg.delivery_id
(+) = wnd.delivery_id AND wnd.delivery_id (+) = wda.delivery_id AND
wdd.source_header_id = ooh.header_id AND csu.site_use_id =
ooh.ship_to_org_id AND os.set_id (+) = wdd.ship_set_id AND
wda.delivery_detail_id = wdd.delivery_detail_id AND ol.line_id =
wdd.source_line_id AND wpsv.transaction_id = ol.line_id AND
wpsv.transaction_id = wdd.source_line_id AND r.customer_id =
wdd.customer_id AND mtrl.header_id = mtrh.header_id AND mtrl.line_id =
wdd.move_order_line_id AND mtrl.inventory_item_id = wpsv.inventory_item_id
AND mtrl.line_id = wpsv.move_order_line_id AND msi.inventory_item_id =
wdd.inventory_item_id AND msi.organization_id = mtrl.organization_id AND
iim.item_no = msi.segment1 AND mtrl.organization_id = : p_organization_id
AND mtrl.organization_id = mp.organization_id and mtrh.request_number
between : p_move_order_low and : p_move_order_high and wpsv.line_status =
'UNPICKED' GROUP BY mp.organization_name , mp.organization_code ,
csu.location , wpsv.pick_slip_number , wpsv.from_subinventory ,
wpsv.from_locator_id , wpsv.to_subinventory , wpsv.to_locator_id ,
mtrh.request_number , wpsv.detailing_date , mtrl.line_id ,
wpsv.transaction_id , wdd.move_order_line_id , to_char (
wdd.source_header_id ) , to_char ( wdd.source_line_id ) ,
wdd.source_header_id , wdd.source_line_id , mtrl.line_number , wtr.trip_id ,
wtr.name , wnd.delivery_id , wnd.name , wdd.shipping_instructions ,
wdd.packing_instructions , r.customer_name , wdd.source_header_number ,
ol.line_number , ol.schedule_ship_date , wdd.ship_tolerance_above ,
wdd.ship_tolerance_below , msi.description , msi.segment1 , msi.description
, wdd.inventory_item_id , os.set_name , wdd.requested_quantity_uom ,
wdd.requested_quantity_uom2 , wpsv.transaction_id , wpsv.line_status ,
wdd.revision , wpsv.primary_qty , wpsv.trans_um1 , wpsv.secondary_qty ,
wpsv.trans_um2 , wpsv.qc_grade , wpsv.lot_id , wpsv.lot_no ,
iim.attribute19 , wpsv.location , SUBSTR ( wpsv.location , 1 , 3 ) ORDER BY
1 ASC,2 ASC,10 ASC,6 ASC,4 ASC,17 ASC,5 ASC,7 ASC,8 ASC,9 ASC,13 ASC,12 ASC,
55 ASC,43 ASC,14 ASC,19 ASC,18 ASC,39 ASC,53 ASC,29 ASC,36 ASC,37 ASC,38
ASC,30 ASC,41 ASC,31 ASC,42 ASC,40 ASC,33 ASC,34 ASC,35 ASC,27 ASC,28 ASC,
20 ASC,21 ASC,22 ASC,23 ASC,26 ASC,24 ASC,25 ASC , mp.organization_code ,
mo_number , pick_slip_number , mo_line_number , item_info
2) Explain plan when the query is taking less than a minute
Rows Row Source Operation
1 SORT UNIQUE (cr=1299 r=87 w=0 time=50693 us)
1 SORT GROUP BY (cr=1299 r=87 w=0 time=50475 us)
1 FILTER (cr=1299 r=87 w=0 time=50009 us)
1 NESTED LOOPS (cr=1299 r=87 w=0 time=50002 us)
1 NESTED LOOPS (cr=1296 r=87 w=0 time=49937 us)
1 NESTED LOOPS (cr=1293 r=87 w=0 time=49873 us)
1 NESTED LOOPS (cr=1290 r=87 w=0 time=49799 us)
1 NESTED LOOPS (cr=1287 r=87 w=0 time=49740 us)
1 NESTED LOOPS OUTER (cr=1284 r=87 w=0 time=49676 us)
1 NESTED LOOPS OUTER (cr=1284 r=87 w=0 time=49654 us)
1 NESTED LOOPS OUTER (cr=1284 r=87 w=0 time=49633 us)
1 NESTED LOOPS OUTER (cr=1282 r=87 w=0 time=49566 us)
1 NESTED LOOPS (cr=1279 r=87 w=0 time=49490 us)
1 NESTED LOOPS (cr=1276 r=87 w=0 time=49381 us)
1 NESTED LOOPS (cr=1273 r=87 w=0 time=49287 us)
1 NESTED LOOPS OUTER (cr=1270 r=87 w=0 time=49209 us)
1 NESTED LOOPS (cr=1270 r=87 w=0 time=49182 us)
1 NESTED LOOPS (cr=1267 r=87 w=0 time=49043 us)
1 NESTED LOOPS (cr=19 r=0 w=0 time=4308 us)
1 NESTED LOOPS (cr=16 r=0 w=0 time=4207 us)
1 NESTED LOOPS (cr=13 r=0 w=0 time=4076 us)
1 NESTED LOOPS (cr=5 r=0 w=0 time=781 us)
1 TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 r=0 w=0 time=111 us)
1 INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 r=0 w=0 time=60 us)(object id 37657)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS_TL (cr=3 r=0 w=0 time=636 us)
1 INDEX UNIQUE SCAN HR_ALL_ORGANIZATION_UNTS_TL_PK (cr=2 r=0 w=0 time=605 us)(object id 44637)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS (cr=8 r=0 w=0 time=3278 us)
1 INDEX UNIQUE SCAN HR_ORGANIZATION_UNITS_PK (cr=1 r=0 w=0 time=31 us)(object id 43498)
1 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_HEADERS (cr=3 r=0 w=0 time=104 us)
1 INDEX RANGE SCAN IC_TXN_REQUEST_HEADERS_U1 (cr=2 r=0 w=0 time=67 us)(object id 637615)
1 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=3 r=0 w=0 time=84 us)
1 INDEX RANGE SCAN IC_TXN_REQUEST_LINES_U1 (cr=2 r=0 w=0 time=53 us)(object id 637626)
1 VIEW (cr=1248 r=87 w=0 time=44702 us)
1 UNION-ALL PARTITION (cr=1248 r=87 w=0 time=44669 us)
1 NESTED LOOPS (cr=1248 r=87 w=0 time=44561 us)
1 NESTED LOOPS (cr=1244 r=87 w=0 time=44429 us)
1 NESTED LOOPS (cr=13 r=0 w=0 time=322 us)
1 NESTED LOOPS (cr=11 r=0 w=0 time=281 us)
1 NESTED LOOPS (cr=9 r=0 w=0 time=228 us)
1 NESTED LOOPS (cr=6 r=0 w=0 time=156 us)
1 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=3 r=0 w=0 time=64 us)
1 INDEX UNIQUE SCAN IC_TXN_REQUEST_LINES_PK (cr=2 r=0 w=0 time=38 us)(object id 637620)
1 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=3 r=0 w=0 time=74 us)
1 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=2 r=0 w=0 time=41 us)(object id 38017)
1 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=3 r=0 w=0 time=60 us)
1 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=2 r=0 w=0 time=38 us)(object id 637202)
1 INDEX UNIQUE SCAN IC_ITEM_MST_TL_PK (cr=2 r=0 w=0 time=33 us)(object id 637049)
1 INDEX UNIQUE SCAN IC_TXN_REQUEST_HEADERS_PK (cr=2 r=0 w=0 time=33 us)(object id 637610)
1 TABLE ACCESS BY INDEX ROWID IC_TRAN_PND (cr=1231 r=87 w=0 time=44078 us)
1907 INDEX RANGE SCAN IC_TRAN_PNDI6 (cr=10 r=0 w=0 time=3000 us)(object id 222381)
1 TABLE ACCESS BY INDEX ROWID IC_LOTS_MST (cr=4 r=0 w=0 time=90 us)
1 INDEX UNIQUE SCAN IC_LOTS_MST_PK (cr=3 r=0 w=0 time=60 us)(object id 637681)
0 FILTER (cr=0 r=0 w=0 time=2 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_TXN_REQUEST_LINES_PK (cr=0 r=0 w=0 time=0 us)(object id 637620)
0 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=0 r=0 w=0 time=0 us)(object id 38017)
0 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=0 r=0 w=0 time=0 us)(object id 637202)
0 INDEX UNIQUE SCAN IC_TXN_REQUEST_HEADERS_PK (cr=0 r=0 w=0 time=0 us)(object id 637610)
0 TABLE ACCESS BY INDEX ROWID IC_TRAN_PND (cr=0 r=0 w=0 time=0 us)
0 INDEX RANGE SCAN IC_TRAN_PNDI6 (cr=0 r=0 w=0 time=0 us)(object id 222381)
0 TABLE ACCESS BY INDEX ROWID IC_LOTS_MST (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_LOTS_MST_PK (cr=0 r=0 w=0 time=0 us)(object id 637681)
1 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_DETAILS (cr=3 r=0 w=0 time=106 us)
1 INDEX RANGE SCAN WSH_DELIVERY_DETAILS_N3 (cr=2 r=0 w=0 time=65 us)(object id 46264)
0 TABLE ACCESS BY INDEX ROWID OE_SETS (cr=0 r=0 w=0 time=3 us)
0 INDEX UNIQUE SCAN OE_SETS_U1 (cr=0 r=0 w=0 time=1 us)(object id 43138)
1 TABLE ACCESS BY INDEX ROWID OE_ORDER_LINES_ALL (cr=3 r=0 w=0 time=58 us)
1 INDEX UNIQUE SCAN OE_ORDER_LINES_U1 (cr=2 r=0 w=0 time=35 us)(object id 42102)
1 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=3 r=0 w=0 time=67 us)
1 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=2 r=0 w=0 time=41 us)(object id 38017)
1 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_ASSIGNMENTS (cr=3 r=0 w=0 time=87 us)
1 INDEX RANGE SCAN WSH_DELIVERY_ASSIGNMENTS_N3 (cr=2 r=0 w=0 time=65 us)(object id 46295)
1 TABLE ACCESS BY INDEX ROWID WSH_NEW_DELIVERIES (cr=3 r=0 w=0 time=49____
1 INDEX UNIQUE SCAN WSH_NEW_DELIVERIES_U1 (cr=2 r=0 w=0 time=28 us)(object id 46306)
0 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_LEGS (cr=2 r=0 w=0 time=37 us)
0 INDEX RANGE SCAN WSH_DELIVERY_LEGS_N1 (cr=2 r=0 w=0 time=35 us)(object id 46235)
0 TABLE ACCESS BY INDEX ROWID WSH_TRIP_STOPS (cr=0 r=0 w=0 time=3 us)
0 INDEX UNIQUE SCAN WSH_TRIP_STOPS_U1 (cr=0 r=0 w=0 time=1 us)(object id 46088)
0 TABLE ACCESS BY INDEX ROWID WSH_TRIPS (cr=0 r=0 w=0 time=2 us)
0 INDEX UNIQUE SCAN WSH_TRIPS_U1 (cr=0 r=0 w=0 time=1 us)(object id 46057)
1 TABLE ACCESS BY INDEX ROWID OE_ORDER_HEADERS_ALL (cr=3 r=0 w=0 time=47 us)
1 INDEX UNIQUE SCAN OE_ORDER_HEADERS_U1 (cr=2 r=0 w=0 time=27 us)(object id 41952)
1 TABLE ACCESS BY INDEX ROWID HZ_CUST_SITE_USES_ALL (cr=3 r=0 w=0 time=44 us)
1 INDEX UNIQUE SCAN HZ_CUST_SITE_USES_U1 (cr=2 r=0 w=0 time=29 us)(object id 236588)
1 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=3 r=0 w=0 time=52 us)
1 INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=2 r=0 w=0 time=34 us)(object id 81600)
1 TABLE ACCESS BY INDEX ROWID HZ_PARTIES (cr=3 r=0 w=0 time=46 us)
1 INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=2 r=0 w=0 time=28 us)(object id 237346)
1 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=3 r=0 w=0 time=41 us)
1 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=2 r=0 w=0 time=24 us)(object id 637202)
3) Explain plan when the query is taking 22mins (for org_id=382)
Rows Row Source Operation
1 SORT UNIQUE (cr=72660499 r=624 w=0 time=1327230739 us)
1 SORT GROUP BY (cr=72660499 r=624 w=0 time=1327230336 us)
1 FILTER (cr=72660499 r=624 w=0 time=1327229578 us)
1 NESTED LOOPS (cr=72660499 r=624 w=0 time=1327229570 us)
1 NESTED LOOPS (cr=72660496 r=623 w=0 time=1327217298 us)
1 NESTED LOOPS (cr=72660493 r=623 w=0 time=1327217219 us)
1 NESTED LOOPS OUTER (cr=72660490 r=623 w=0 time=1327217140 us)
1 NESTED LOOPS OUTER (cr=72660490 r=623 w=0 time=1327217118 us)
1 NESTED LOOPS OUTER (cr=72660490 r=623 w=0 time=1327217092 us)
1 NESTED LOOPS OUTER (cr=72660488 r=623 w=0 time=1327217006 us)
1 NESTED LOOPS (cr=72660485 r=622 w=0 time=1327207555 us)
1 NESTED LOOPS (cr=72660480 r=621 w=0 time=1327207177 us)
1 NESTED LOOPS (cr=72660477 r=621 w=0 time=1327207115 us)
1 NESTED LOOPS (cr=72660474 r=621 w=0 time=1327207034 us)
1 NESTED LOOPS (cr=72660471 r=621 w=0 time=1327206951 us)
7 NESTED LOOPS (cr=72660455 r=619 w=0 time=1327206132 us)
7 NESTED LOOPS OUTER (cr=72660439 r=613 w=0 time=1327203302 us)
7 NESTED LOOPS (cr=72660439 r=613 w=0 time=1327203073 us)
14 NESTED LOOPS (cr=72660407 r=610 w=0 time=1327200108 us)
90549 NESTED LOOPS (cr=3359 r=455 w=0 time=1818230 us)
1 NESTED LOOPS (cr=13 r=0 w=0 time=4463 us)
1 NESTED LOOPS (cr=5 r=0 w=0 time=962 us)
1 TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 r=0 w=0 time=107 us)
1 INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 r=0 w=0 time=55 us)(object id 37657)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS_TL (cr=3 r=0 w=0 time=820 us)
1 INDEX UNIQUE SCAN HR_ALL_ORGANIZATION_UNTS_TL_PK (cr=2 r=0 w=0 time=786 us)(object id 44637)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS (cr=8 r=0 w=0 time=3479 us)
1 INDEX UNIQUE SCAN HR_ORGANIZATION_UNITS_PK (cr=1 r=0 w=0 time=23 us)(object id 43498)
90549 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=3346 r=455 w=0 time=1704106 us)
90549 INDEX RANGE SCAN IC_TXN_REQUEST_LINES_N1 (cr=210 r=41 w=0 time=694480 us)(object id 133389)
14 VIEW (cr=72657048 r=155 w=0 time=1324006502 us)
14 UNION-ALL PARTITION (cr=72657048 r=155 w=0 time=1322889352 us)
14 NESTED LOOPS (cr=72657048 r=155 w=0 time=1318179989 us)
14 NESTED LOOPS (cr=72656992 r=151 w=0 time=1318005647 us)
90549 NESTED LOOPS (cr=1177138 r=52 w=0 time=20959096 us)
90549 NESTED LOOPS (cr=996040 r=51 w=0 time=18410001 us)
90549 NESTED LOOPS (cr=814942 r=51 w=0 time=15523206 us)
90549 NESTED LOOPS (cr=543294 r=50 w=0 time=10944790 us)
90549 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=271647 r=1 w=0 time=5063466 us)
90549 INDEX UNIQUE SCAN IC_TXN_REQUEST_LINES_PK (cr=181098 r=1 w=0 time=2863447 us)(object id 637620)
90549 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=271647 r=49 w=0 time=4794430 us)
90549 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=181098 r=1 w=0 time=2553802 us)(object id 38017)
90549 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=271648 r=1 w=0 time=3786267 us)
90549 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=181098 r=0 w=0 time=2164425 us)(object id 637202)
90549 INDEX UNIQUE SCAN IC_ITEM_MST_TL_PK (cr=181098 r=0 w=0 time=2260794 us)(object id 637049)
90549 INDEX UNIQUE SCAN IC_TXN_REQUEST_HEADERS_PK (cr=181098 r=1 w=0 time=1902881 us)(object id 637610)
14 TABLE ACCESS BY INDEX ROWID IC_TRAN_PND (cr=71479854 r=99 w=0 time=1295671259 us)
101213210 INDEX RANGE SCAN IC_TRAN_PNDI6 (cr=676173 r=21 w=0 time=136382307 us)(object id 222381)
14 TABLE ACCESS BY INDEX ROWID IC_LOTS_MST (cr=56 r=4 w=0 time=2052 us)
14 INDEX UNIQUE SCAN IC_LOTS_MST_PK (cr=42 r=2 w=0 time=1265 us)(object id 637681)
0 FILTER (cr=0 r=0 w=0 time=59787 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 NESTED LOOPS (cr=0 r=0 w=0 time=0 us)
0 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_LINES (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_TXN_REQUEST_LINES_PK (cr=0 r=0 w=0 time=0 us)(object id 637620)
0 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=0 r=0 w=0 time=0 us)(object id 38017)
0 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=0 r=0 w=0 time=0 us)(object id 637202)
0 INDEX UNIQUE SCAN IC_TXN_REQUEST_HEADERS_PK (cr=0 r=0 w=0 time=0 us)(object id 637610)
0 TABLE ACCESS BY INDEX ROWID IC_TRAN_PND (cr=0 r=0 w=0 time=0 us)
0 INDEX RANGE SCAN IC_TRAN_PNDI6 (cr=0 r=0 w=0 time=0 us)(object id 222381)
0 TABLE ACCESS BY INDEX ROWID IC_LOTS_MST (cr=0 r=0 w=0 time=0 us)
0 INDEX UNIQUE SCAN IC_LOTS_MST_PK (cr=0 r=0 w=0 time=0 us)(object id 637681)
7 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_DETAILS (cr=32 r=3 w=0 time=2586 us)
14 INDEX RANGE SCAN WSH_DELIVERY_DETAILS_N3 (cr=16 r=1 w=0 time=1221 us)(object id 46264)
0 TABLE ACCESS BY INDEX ROWID OE_SETS (cr=0 r=0 w=0 time=32 us)
0 INDEX UNIQUE SCAN OE_SETS_U1 (cr=0 r=0 w=0 time=6 us)(object id 43138)
7 TABLE ACCESS BY INDEX ROWID OE_ORDER_LINES_ALL (cr=16 r=6 w=0 time=2715 us)
7 INDEX UNIQUE SCAN OE_ORDER_LINES_U1 (cr=9 r=2 w=0 time=1399 us)(object id 42102)
1 TABLE ACCESS BY INDEX ROWID IC_TXN_REQUEST_HEADERS (cr=16 r=2 w=0 time=679 us)
7 INDEX UNIQUE SCAN IC_TXN_REQUEST_HEADERS_PK (cr=9 r=0 w=0 time=124 us)(object id 637610)
1 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=3 r=0 w=0 time=50 us)
1 INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=2 r=0 w=0 time=23 us)(object id 38017)
1 TABLE ACCESS BY INDEX ROWID OE_ORDER_HEADERS_ALL (cr=3 r=0 w=0 time=58 us)
1 INDEX UNIQUE SCAN OE_ORDER_HEADERS_U1 (cr=2 r=0 w=0 time=36 us)(object id 41952)
1 TABLE ACCESS BY INDEX ROWID IC_ITEM_MST_B (cr=3 r=0 w=0 time=33 us)
1 INDEX UNIQUE SCAN IC_ITEM_MST_B_UNQ1 (cr=2 r=0 w=0 time=14 us)(object id 637202)
1 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_ASSIGNMENTS (cr=5 r=1 w=0 time=358 us)
1 INDEX RANGE SCAN WSH_DELIVERY_ASSIGNMENTS_N3 (cr=2 r=0 w=0 time=68 us)(object id 46295)
1 TABLE ACCESS BY INDEX ROWID WSH_NEW_DELIVERIES (cr=3 r=1 w=0 time=9428 us)
1 INDEX UNIQUE SCAN WSH_NEW_DELIVERIES_U1 (cr=2 r=1 w=0 time=9405 us)(object id 46306)
0 TABLE ACCESS BY INDEX ROWID WSH_DELIVERY_LEGS (cr=2 r=0 w=0 time=58 us)
0 INDEX RANGE SCAN WSH_DELIVERY_LEGS_N1 (cr=2 r=0 w=0 time=55 us)(object id 46235)
0 TABLE ACCESS BY INDEX ROWID WSH_TRIP_STOPS (cr=0 r=0 w=0 time=2 us)
0 INDEX UNIQUE SCAN WSH_TRIP_STOPS_U1 (cr=0 r=0 w=0 time=1 us)(object id 46088)
0 TABLE ACCESS BY INDEX ROWID WSH_TRIPS (cr=0 r=0 w=0 time=1 us)
0 INDEX UNIQUE SCAN WSH_TRIPS_U1 (cr=0 r=0 w=0 time=1 us)(object id 46057)
1 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=3 r=0 w=0 time=55 us)
1 INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=2 r=0 w=0 time=34 us)(object id 81600)
1 TABLE ACCESS BY INDEX ROWID HZ_PARTIES (cr=3 r=0 w=0 time=48 us)
1 INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=2 r=0 w=0 time=26 us)(object id 237346)
1 TABLE ACCESS BY INDEX ROWID HZ_CUST_SITE_USES_ALL (cr=3 r=1 w=0 time=12241 us)
1 INDEX UNIQUE SCAN HZ_CUST_SITE_USES_U1 (cr=2 r=1 w=0 time=12187 us)(object id 236588) -
Hi All,
We have a query which is taking hell lot of time in production due to Full Table Scan on the table AP_ACCOUNTING_EVENTS.
We have then tried to force the index AP_ACCOUNTING_EVENTS_N1 on the query by applying hints.
Now the table is doing a range scan using index AP_ACCOUNTING_EVENTS_N1.
But to my surprise, the query with hints is taking even more time than that of query without hint.
Database: 10.0.2
and Application : 11.5.10.2
PFB the query:
SELECT api.invoice_id,
SUBSTR(pov.segment1, 1, 5) supplier_code,
DECODE(pov.segment1,
'A',
SUBSTR(api.attribute7, 1, 20),
SUBSTR(pov.vendor_name, 1, 20)) supplier_name,
MIN(TRUNC(aae.creation_date)) approval_date
FROM po_vendors pov, ap_invoices api, ap_accounting_events aae
WHERE api.payment_status_flag = 'Y'
AND api.source not in ('A', 'B', 'C')
AND aae.source_table = 'AP_INVOICES'
AND aae.creation_date >= sysdate - 2
AND aae.creation_Date < sysdate
AND aae.accounting_event_id = aae.ACCOUNTING_EVENT_ID
AND pov.vendor_id = api.vendor_id
AND aae.source_id = api.invoice_id
GROUP BY api.invoice_id,
SUBSTR(pov.segment1, 1, 5),
DECODE(pov.segment1,
'A',
SUBSTR(api.attribute7, 1, 20),
SUBSTR(pov.vendor_name, 1, 20))
Kindly Help.
Thanks,Tuning request
Take a look at the
When your query takes too long ...
HOW TO: Post a SQL statement tuning request - template posting -
Hi All,
I need your help in framing a query.
I need to populate a multi-record block having, say 2 where conditions. Hold on...its not straight forward...
An example:
I need to select EMPNO, ENAME, SAL from EMP
where DEPTNO in ()
and JOB in ()
I have a multi-record block for DEPTNO with check-boxes for each DEPTNO and another block for JOB as well.
What I am currently doing is whenever a check-box is selected in the DEPTNO block I capture the value in a variable, say v_selectdeptno and similarly for JOB, say in v_selectjob with appropriate quotes as well (like 'CLERK','SALESMAN').
Now my query looked like:
Cursor C1 is
select EMPNO, ENAME, SAL from EMP
where DEPTNO in (v_selectdeptno)
and JOB in (v_selectjob);
The values in the variable for v_selectdeptno were '10','20' (in this example please assume DEPTNO is a varchar2 datatype)
and for v_selectjob were 'CLERK','SALESMAN'.
Now if I fetch this loop into the multi-record block where it has to be displayed I don't get any result. But the same query works fine if the values selected are just one, meaning '10' for v_selectdeptno and 'CLERK' for v_selectjob.
I am not sure what I am missing here. Please do help. I hope I have explained my problem clearly.
Thanks in advance.This block will parse the parse_Str variable into a comma delimited quoted string. Please note it is not tested and may not be be optimally written but it should give you an idea of how to build the string. Remember if you are dealing with numbers you will not need quotes.
You can run it in sql*plus but remember to SET SERVEROUTPUT ON and DBMS_OUTPUT.ENABLE(100000); if you need them.
DECLARE
parse_str varchar2(200) := '10,20,30,40,100';
where_clause varchar2(4000) := 'deptno in (';
value varchar2(200) := null;
end_pos number := 1;
function q(str in varchar2) return varchar2 is
begin
return ''''||str||'''';
end;
BEGIN
while true loop
end_pos := instr(parse_str,',');
if end_pos = 0 then
value := substr(parse_str,1);
where_clause := where_clause||q(value)||')';
else
value := substr(parse_str,1,end_pos - 1);
where_clause := where_clause||q(value)||',';
end if;
parse_str := substr(parse_str,end_pos + 1);
exit when end_pos = 0;
end loop;
dbms_output.put_line(where_clause);
END;
Hope it is useful to you
Maybe you are looking for
-
FIREFOX FRONTMOTION DROP DOWN MENU NOT WORKING
My company recently gave us Frontmotion Firefox, I am so happy to finally quit using IE. My company's website works fine with IE, all is well except on mouseover the drop down menus do not appear (This is also true for any website I try). I have look
-
How can I transfer the rights of a book from one account to another?
I have two books on an older Adobe account that I don't use anymore. Now that I have a new account with a different e-mail address, is there anyway to get those 2 books on the new account without buying them again? I can verify that both accounts are
-
I'm running Priemier Elements 8.01 on Windows 7 64-bit. Graphics card is a Nvidia GeForce 8400 GS, driver version 197.45 Whenever I open Premire Elements 8, I get a little Red X error in the bottom corner saying that my graphics card or driver may be
-
How to save Adobe form to scripted, specified location
After the adobe form is filled, I would like to develop a "save" button that predetermines where the file is to be stored and what the name is (based on a field that is filled in + a date. If there is anyone that can point me to the right direction,
-
SqlDeveloper on Suse Desktop 10 64-bit
I have installed sqldeveloper on Suse Desktop 10 (sled 10) x86_64 and receive a null pointer exception. It runs ok on Suse 10.1 x86 (32-bit) on the same machine. Oracle SQL Developer 1.0 Copyright (c) 2005 Oracle Corporation. All Rights Reserved. Wor