Need help in performance tunning
Hi , i have one update statement , where it is keep on running for hours and the volume of the data is 2.2 million
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 Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
below is the code :
DECLARE
Cursor C11
Is
Select Account_Num,Outlet_Num,Product_Number,Ln_Of_Biz,Generateguid('DELIVERED_PRODUCT') As Dp_Guid From (
Select Account_Num,Outlet_Num,Product_Number,Ln_Of_Biz
From transformation_flat
Group By Account_Num, Outlet_Num,Ln_Of_Biz,Product_Number
Having Count(*)> 1);
Type Actno Is Table Of Varchar2(13) Index By Binary_Integer;
Type Outlet Is Table Of NUMBER Index By Binary_Integer;
Type Pno Is Table Of VARCHAR2(255) INDEX BY BINARY_INTEGER;
Type Tn Is Table Of VARCHAR2(10) Index By Binary_Integer;
Type Vdpguid Is Table Of VARCHAR2(20) Index By Binary_Integer;
Type Vcnt Is Table Of Number Index By Binary_Integer;
Type Lob1 Is Table Of Varchar2(255) Index By Binary_Integer;
Type Offer_No Is Table Of Varchar2(255) Index By Binary_Integer;
V_Actno Actno;
V_Outlet Outlet;
V_Pno Pno;
V_Tn Tn;
V_DPGUID VDPGUID;
Vguid Varchar2(20);
V_Cnt Vcnt;
V_Lob Lob1;
V_Offer_No Offer_No;
BEGIN
Open c11;
Loop
Fetch C11 Bulk Collect Into V_Actno,V_Outlet,V_Pno,V_Lob,V_Dpguid;
Exit When C11%Notfound;
End Loop;
close c11;
Forall I In 1..V_Actno.count
Update transformation_flat Set Product_Guid=V_Dpguid(I) Where
Account_Num=V_Actno(I) And
Outlet_Num=V_Outlet(I) And
Product_Number=V_Pno(I) And
ln_of_biz=v_lob(I);
Commit;
END;
for above i do have index on that table on (account_num,outlet_num,product_number,ln_of_biz).
when i checked the memory contents for this sqlid in v$sql , below are the values :
Disk_Read:21640650
Buffer_Gets:22466856
Concurrency_Wait_Time:16923
Cluster_Wait_Time:36313694
user_io_wait_time:3594365433
I need some inputs in which area i can tune the above code..
Thanks
835589 wrote:
hi i am also face same performance issue pls reply me ASApDon't use the word ASAP, it is rude and a violation of forum terms and conditions.
http://www.oracle.com/html/terms.html
>
4. Use of Community Services
Community Services are provided as a convenience to users and Oracle is not obligated to provide any technical support for, or participate in, Community Services. While Community Services may include information regarding Oracle products and services, including information from Oracle employees, they are not an official customer support channel for Oracle.
You may use Community Services subject to the following: (a) Community Services may be used solely for your personal, informational, noncommercial purposes; (b) Content provided on or through Community Services may not be redistributed; and (c) personal data about other users may not be stored or collected except where expressly authorized by Oracle
>
These people are for ASAP requests.
http://www.google.com/search?q=oracle+consultant
where i need to tune the queery.
pls i am eagarly waiting for that
Read and understand the links posted above
RPuttagunta wrote:
HOW TO: Post a SQL statement tuning request - template posting
When your query takes too long ...
Similar Messages
-
Need help for performance tunning
Hello,
I have 16K records return by query, it takes long time to proceed for 7K it takes 7.5 sec.
Note: I used all seeded tables only.
If possible please help me to tune it.
SELECT msi.inventory_item_id,msi.segment1,msi.rimary_uom_code , msi.primary_unit_of_measure
FROM mtl_system_items_b msi, qp_list_lines qpll,qp_pricing_attributes qppr,
mtl_category_sets_tl mcs,mtl_category_sets_b mcsb,
mtl_categories_b mc, mtl_item_categories mcb
WHERE msi.enabled_flag = 'Y'
AND qpll.list_line_id = qppr.list_line_id
AND qppr.product_attr_value = TO_CHAR (msi.inventory_item_id(+))
AND qppr.product_uom_code = msi.primary_uom_code
AND mc.category_id = mcb.category_id
AND msi.inventory_item_id = mcb.inventory_item_id
AND msi.organization_id = mcb.organization_id
AND TRUNC (SYSDATE) BETWEEN NVL (qpll.start_date_active,TRUNC (SYSDATE)) AND NVL (qpll.end_date_active,TRUNC (SYSDATE))
AND mcs.category_set_name = 'LSS SALES CATEGORY'
AND mcs.language = 'US'
AND mcs.category_set_id = mcsb.category_set_id
AND mcsb.structure_id = mc.structure_id
AND msi.organization_id = :p_organization_id
AND qpll.list_header_id = :p_price_list_id
AND mcb.category_id = :p_category_id;
Thanks and regards
Akil.Thanks Helios ,
here is answers
Databse version
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit
PL/SQL Release 11.1.0.7.0
explain plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
|
0 | SELECT STATEMENT
| |
1 | 149 | 9439
(1)|
|
1 | NESTED LOOPS | | 1 |
149 | 9439 (1)|
|*
2 | HASH JOIN OUTER | | 1 |
135 | 9437 (1)|
|*
3 | HASH JOIN | | 1 |
71 | 9432 (1)|
|
4 | NESTED LOOPS | | 2 |
76 | 53 (0)|
|*
5 | TABLE ACCESS BY INDEX
ROWID| QP_LIST_LINES | 2 |
44 | 49 (0)|
|*
6 | INDEX SKIP SCAN | QP_LIST_LINES_N2 |
702 | | 20
(0)|
|*
7 | INDEX RANGE SCAN | QP_PRICING_ATTRIBUTES_N3 | 1 |
16 | 2 (0)|
|*
8 | TABLE ACCESS BY INDEX
ROWID | MTL_SYSTEM_ITEMS_B | 46254
| 1490K|
9378 (1)|
|*
9 | INDEX RANGE SCAN | MTL_SYSTEM_ITEMS_B_N9 | 46254 | |
174 (1)|
|
10 | TABLE ACCESS FULL | XX_WEB_ITEM_IMAGE_TBL |
277 | 17728 | 5 (0)|
|* 11 | INDEX RANGE SCAN | MTL_ITEM_CATEGORIES_U1 |
1 | 14 | 2
(0)|
Predicate Information (identified
by operation id):
2 -
access("XWIIT"."IMAGE_CODE"(+)="MSI"."SEGMENT1")
3 -
access("QPPR"."PRODUCT_ATTR_VALUE"=TO_CHAR("MSI"."INVENTORY_ITEM_ID")
AND
"QPPR"."PRODUCT_UOM_CODE"="MSI"."PRIMARY_UOM_CODE")
5 - filter(NVL("QPLL"."START_DATE_ACTIVE",TRUNC(SYSDATE@!))<=TRUNC(SYSDATE@!)
AND
NVL("QPLL"."END_DATE_ACTIVE",TRUNC(SYSDATE@!))>=TRUNC(SYSDATE@!))
6 -
access("QPLL"."LIST_HEADER_ID"=TO_NUMBER(:P_PRICE_LIST_ID))
filter("QPLL"."LIST_HEADER_ID"=TO_NUMBER(:P_PRICE_LIST_ID))
7 -
access("QPLL"."LIST_LINE_ID"="QPPR"."LIST_LINE_ID")
filter("QPPR"."PRODUCT_UOM_CODE" IS NOT NULL)
8 - filter("MSI"."ENABLED_FLAG"='Y')
9 - access("MSI"."ORGANIZATION_ID"=TO_NUMBER(:P_ORGANIZATION_ID))
11 -
access("MCB"."ORGANIZATION_ID"=TO_NUMBER(:P_ORGANIZATION_ID)
AND
"MSI"."INVENTORY_ITEM_ID"="MCB"."INVENTORY_ITEM_ID"
AND
"MCB"."CATEGORY_ID"=TO_NUMBER(:P_CATEGORY_ID))
filter("MCB"."CATEGORY_ID"=TO_NUMBER(:P_CATEGORY_ID))
Note
- 'PLAN_TABLE' is old version
TKprof Plan
TKPROF: Release 11.1.0.7.0 - Production on Fri Nov 15 06:12:26 2013
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Trace file: LSSD_ora_19760.trc
Sort options: default
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
SELECT msi.inventory_item_id,
msi.segment1,
primary_uom_code,
primary_unit_of_measure,
xwiit.image_url
FROM mtl_system_items_b msi,
qp_list_lines qpll,
qp_pricing_attributes qppr,
mtl_item_categories mcb,
xx_web_item_image_tbl xwiit
WHERE msi.enabled_flag = 'Y'
AND qpll.list_line_id = qppr.list_line_id
AND qppr.product_attr_value = TO_CHAR (msi.inventory_item_id)
AND qppr.product_uom_code = msi.primary_uom_code
AND msi.inventory_item_id = mcb.inventory_item_id
AND msi.organization_id = mcb.organization_id
AND TRUNC (SYSDATE) BETWEEN NVL (qpll.start_date_active,
TRUNC (SYSDATE))
AND NVL (qpll.end_date_active,
TRUNC (SYSDATE))
AND xwiit.image_code(+) = msi.segment1
AND msi.organization_id = :p_organization_id
AND qpll.list_header_id = :p_price_list_id
AND mcb.category_id = :p_category_id
call count cpu elapsed disk query current rows
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 3.84 3.85 0 432560 0 1002
total 6 3.84 3.85 0 432560 0 1002
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 173
Rows Row Source Operation
501 NESTED LOOPS (cr=216280 pr=0 pw=0 time=115 us cost=9439 size=149 card=1)
2616 HASH JOIN OUTER (cr=211012 pr=0 pw=0 time=39 us cost=9437 size=135 card=1)
78568 HASH JOIN (cr=210997 pr=0 pw=0 time=3786 us cost=9432 size=71 card=1)
78571 NESTED LOOPS (cr=29229 pr=0 pw=0 time=35533 us cost=53 size=76 card=2)
78571 TABLE ACCESS BY INDEX ROWID QP_LIST_LINES (cr=9943 pr=0 pw=0 time=27533 us cost=49 size=44 card=2)
226733 INDEX SKIP SCAN QP_LIST_LINES_N2 (cr=865 pr=0 pw=0 time=4122 us cost=20 size=0 card=702)(object id 99730)
78571 INDEX RANGE SCAN QP_PRICING_ATTRIBUTES_N3 (cr=19286 pr=0 pw=0 time=0 us cost=2 size=16 card=1)(object id 99733)
128857 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=181768 pr=0 pw=0 time=9580 us cost=9378 size=1526382 card=46254)
128857 INDEX RANGE SCAN MTL_SYSTEM_ITEMS_B_N9 (cr=450 pr=0 pw=0 time=1657 us cost=174 size=0 card=46254)(object id 199728)
277 TABLE ACCESS FULL XX_WEB_ITEM_IMAGE_TBL (cr=15 pr=0 pw=0 time=22 us cost=5 size=17728 card=277)
501 INDEX RANGE SCAN MTL_ITEM_CATEGORIES_U1 (cr=5268 pr=0 pw=0 time=0 us cost=2 size=14 card=1)(object id 99557)
Note: I modified query and it gives good result, now it takes 3 to 4 sec for 16000 records.
If possible can you plz explain what we have to take care while doing performance tunning
I am a fresher so don't have that much idea.
and also Thanks Hussein for your replay -
Need help in Performance tuning for function...
Hi all,
I am using the below algorithm for calculating the Luhn Alogorithm to calculate the 15th luhn digit for an IMEI (Phone Sim Card).
But the below function is taking about 6 min for 5 million records. I had 170 million records in a table want to calculate the luhn digit for all of them which might take up to 4-5 hours.Please help me performance tuning (better way or better logic for luhn calculation) to the below function.
A wikipedia link is provided for the luhn algorithm below
Create or Replace FUNCTION AddLuhnToIMEI (LuhnPrimitive VARCHAR2)
RETURN VARCHAR2
AS
Index_no NUMBER (2) := LENGTH (LuhnPrimitive);
Multiplier NUMBER (1) := 2;
Total_Sum NUMBER (4) := 0;
Plus NUMBER (2);
ReturnLuhn VARCHAR2 (25);
BEGIN
WHILE Index_no >= 1
LOOP
Plus := Multiplier * (TO_NUMBER (SUBSTR (LuhnPrimitive, Index_no, 1)));
Multiplier := (3 - Multiplier);
Total_Sum := Total_Sum + TO_NUMBER (TRUNC ( (Plus / 10))) + MOD (Plus, 10);
Index_no := Index_no - 1;
END LOOP;
ReturnLuhn := LuhnPrimitive || CASE
WHEN MOD (Total_Sum, 10) = 0 THEN '0'
ELSE TO_CHAR (10 - MOD (Total_Sum, 10))
END;
RETURN ReturnLuhn;
EXCEPTION
WHEN OTHERS
THEN
RETURN (LuhnPrimitive);
END AddLuhnToIMEI;
http://en.wikipedia.org/wiki/Luhn_algorithmAny sort of help is much appreciated....
Thanks
RedeThere is a not needed to_number function in it. TRUNC will already return a number.
Also the MOD function can be avoided at some steps. Since multiplying by 2 will never be higher then 18 you can speed up the calculation with this.
create or replace
FUNCTION AddLuhnToIMEI_fast (LuhnPrimitive VARCHAR2)
RETURN VARCHAR2
AS
Index_no pls_Integer;
Multiplier pls_Integer := 2;
Total_Sum pls_Integer := 0;
Plus pls_Integer;
rest pls_integer;
ReturnLuhn VARCHAR2 (25);
BEGIN
for Index_no in reverse 1..LENGTH (LuhnPrimitive) LOOP
Plus := Multiplier * TO_NUMBER (SUBSTR (LuhnPrimitive, Index_no, 1));
Multiplier := 3 - Multiplier;
if Plus < 10 then
Total_Sum := Total_Sum + Plus ;
else
Total_Sum := Total_Sum + Plus - 9;
end if;
END LOOP;
rest := MOD (Total_Sum, 10);
ReturnLuhn := LuhnPrimitive || CASE WHEN rest = 0 THEN '0' ELSE TO_CHAR (10 - rest) END;
RETURN ReturnLuhn;
END AddLuhnToIMEI_fast;
/My tests gave an improvement for about 40%.
The next step to try could be to use native complilation on this function. This can give an additional big boost.
Edited by: Sven W. on Mar 9, 2011 8:11 PM -
Hi,
I am looking for some help in tuning a query and details are below.
SELECT NVL(B.START_DATE_TIME,
A.START_DATE_TIME) START_DATE,
NVL(B.CUST_PRODUCTION_SEQ_NUM,
A.CUST_PRODUCTION_SEQ_NUM) PROD_NUM,
A.HEADER_ID NEW_HEADER_ID,
B.HEADER_ID OLD_HEADER_ID,
A.LINE_ID,
B.LINE_ID,
A.QTY_TYPE_CODE NEW_CODE,
B.QTY_TYPE_CODE OLD_CODE,
NVL(B.SHIP_FROM_ORG_ID,
A.SHIP_FROM_ORG_ID) SHIP_FROM_ORG_ID,
-- hrorg.name ship_from_name ,
NVL(B.SHIP_TO_ORG_ID,
A.SHIP_TO_ORG_ID) SHIP_TO_ORG_ID,
NVL(B.BILL_TO_ADDRESS_ID,
A.BILL_TO_ADDRESS_ID) BILL_TO_ADDRESS_ID,
NVL(B.SHIP_TO_ADDRESS_ID,
A.SHIP_TO_ADDRESS_ID) SHIP_TO_ADDRESS_ID,
NVL(B.SHIP_TO_NAME_EXT,
A.SHIP_TO_NAME_EXT) SHIP_TO_NAME,
NVL(B.INTRMD_SHIP_TO_ID,
A.INTRMD_SHIP_TO_ID) INTRMD_SHIP_TO_ID,
NVL(B.CUSTOMER_ITEM_ID,
A.CUSTOMER_ITEM_ID) CUSTOMER_ITEM_ID,
--mci.customer_item_desc customer_item_desc,
NVL(B.INVENTORY_ITEM_ID,
A.INVENTORY_ITEM_ID) INVENTORY_ITEM_ID,
NVL(B.ITEM_DETAIL_SUBTYPE,
A.ITEM_DETAIL_SUBTYPE) ITEM_DETAIL_SUBTYPE,
FND1.MEANING DETAIL_SUBTYPE,
NVL(B.UOM_CODE,
A.UOM_CODE) UOM_CODE,
NVL(B.CUST_PO_NUMBER,
A.CUST_PO_NUMBER) CUST_PO_NUMBER,
NVL(B.INDUSTRY_ATTRIBUTE1,
A.INDUSTRY_ATTRIBUTE1) CUST_RECORD_YEAR,
A.ITEM_DETAIL_QUANTITY,
A.ITEM_DETAIL_TYPE,
FND2.MEANING NEW_DETAIL_TYPE,
B.ITEM_DETAIL_QUANTITY,
B.ITEM_DETAIL_TYPE,
FND3.MEANING OLD_DETAIL_TYPE
FROM RLM_SCHEDULE_LINES_ALL A,
(SELECT * FROM RLM_SCHEDULE_LINES_ALL b_in
WHERE TRUNC(b_in.START_DATE_TIME) >=
(SELECT TRUNC(SCHED_HORIZON_START_DATE)
FROM RLM_SCHEDULE_HEADERS
WHERE HEADER_ID = :P_NEW_HEADER_ID)---
AND TRUNC(b_in.START_DATE_TIME) <=
(SELECT TRUNC(SCHED_HORIZON_END_DATE)
FROM RLM_SCHEDULE_HEADERS
WHERE HEADER_ID = :P_NEW_HEADER_ID)
AND HEADER_ID = (SELECT header_id
FROM apps.rlm_schedule_headers_all
WHERE header_id =
(SELECT MAX(rsha.header_id)
FROM apps.rlm_schedule_headers_all rsha,
apps.rlm_schedule_lines_all rsla
WHERE rsha.customer_id = :p_customer_id
AND rsha.schedule_type = :p_schedule_type
AND rsla.inventory_item_id = b_in.inventory_item_id ---
AND rsla.org_id = rsha.org_id
AND (((rsla.cust_po_number = b_in.cust_po_number)AND
EXISTS (SELECT 'x'
FROM FND_LOOKUP_VALUES_VL FLV,
RA_CUSTOMERS RC
WHERE FLV.LOOKUP_TYPE = 'TEST_RLM_CHECK_CUST'
AND FLV.MEANING = RC.CUSTOMER_NAME
AND RC.CUSTOMER_ID = :P_CUSTOMER_ID))
OR
NOT EXISTS (SELECT 'x'
FROM FND_LOOKUP_VALUES_VL FLV,
RA_CUSTOMERS RC
WHERE FLV.LOOKUP_TYPE = 'TEST_RLM_CHECK_CUST'
AND FLV.MEANING = RC.CUSTOMER_NAME
AND RC.CUSTOMER_ID = :P_CUSTOMER_ID) )---
and rsha.header_id = rsla.header_id
and rsla.ship_from_org_id = :p_ship_from_org_id
AND rsha.ece_tp_location_code_ext = :p_ece_tp_location_code_ext
AND NVL(rsha.header_ref_value_1, '1') =
NVL(rsha.header_ref_value_1, '1')
AND rsha.header_id NOT IN
(SELECT header_id
FROM apps.rlm_schedule_headers_all
WHERE attribute1 = :p_request_id)))) B,
--rlm_schedule_headers c,
-- hr_organization_units hrorg,
--mtl_customer_items mci,
FND_LOOKUPS FND1,
FND_LOOKUPS FND2,
FND_LOOKUPS FND3
-- ra_addresses_all radd2,
-- ra_site_uses_all rsu2
WHERE A.HEADER_ID(+) = :P_NEW_HEADER_ID
----AND B.HEADER_ID = :P_OLD_HEADER_ID
AND A.CUSTOMER_ITEM_ID(+) = B.CUSTOMER_ITEM_ID
AND A.SHIP_TO_ORG_ID(+) = B.SHIP_TO_ORG_ID
AND A.SHIP_FROM_ORG_ID(+) = B.SHIP_FROM_ORG_ID
AND A.INVENTORY_ITEM_ID(+) = B.INVENTORY_ITEM_ID
AND NVL(A.INTRMD_SHIP_TO_ID(+),
NVL(B.INTRMD_SHIP_TO_ID,
0)) = NVL(B.INTRMD_SHIP_TO_ID,
0)
AND A.ITEM_DETAIL_SUBTYPE(+) = B.ITEM_DETAIL_SUBTYPE
AND A.UOM_CODE(+) = B.UOM_CODE
AND NVL(A.CUST_PO_NUMBER(+),
NVL(B.CUST_PO_NUMBER,
0)) = NVL(B.CUST_PO_NUMBER,
0)
AND A.ITEM_DETAIL_TYPE(+) < :P_ITEM_DETAIL_TYPE
AND B.ITEM_DETAIL_TYPE < :P_ITEM_DETAIL_TYPE
AND TRUNC(A.START_DATE_TIME(+)) = TRUNC(B.START_DATE_TIME)
AND FND1.LOOKUP_CODE = NVL(A.ITEM_DETAIL_SUBTYPE,
B.ITEM_DETAIL_SUBTYPE)
AND FND1.LOOKUP_TYPE = :P_RLM_DETAIL_SUBTYPE_CODE
AND NVL(A.ITEM_DETAIL_TYPE,
'0') = FND2.LOOKUP_CODE
AND FND2.LOOKUP_TYPE = :P_RLM_DETAIL_TYPE_CODE
AND FND3.LOOKUP_CODE = B.ITEM_DETAIL_TYPE
AND A.SHIP_FROM_ORG_ID(+) = :P_SHIP_FROM_ORG_ID
AND B.SHIP_FROM_ORG_ID = :P_SHIP_FROM_ORG_ID
AND FND3.LOOKUP_TYPE = :P_RLM_DETAIL_TYPE_CODE
AND B.CUSTOMER_ITEM_ID IN
(SELECT DISTINCT CUSTOMER_ITEM_ID
FROM RLM_SCHEDULE_LINES_ALL
WHERE HEADER_ID = :P_NEW_HEADER_ID) &P_WHERE4 &P_WHERE3
-- CHANGES
&P_WHERE_DATE_A
UNION
SELECT NVL(A.START_DATE_TIME,
B.START_DATE_TIME) START_DATE,
NVL(A.CUST_PRODUCTION_SEQ_NUM,
B.CUST_PRODUCTION_SEQ_NUM) PROD_NUM,
A.HEADER_ID NEW_HEADER_ID,
B.HEADER_ID OLD_HEADER_ID,
A.LINE_ID,
B.LINE_ID,
A.QTY_TYPE_CODE NEW_CODE,
B.QTY_TYPE_CODE OLD_CODE,
NVL(A.SHIP_FROM_ORG_ID,
B.SHIP_FROM_ORG_ID) SHIP_FROM_ORG_ID,
-- hrorg.name ship_from_name ,
NVL(A.SHIP_TO_ORG_ID,
B.SHIP_TO_ORG_ID) SHIP_TO_ORG_ID,
NVL(A.BILL_TO_ADDRESS_ID,
B.BILL_TO_ADDRESS_ID) BILL_TO_ADDRESS_ID,
NVL(A.SHIP_TO_ADDRESS_ID,
B.SHIP_TO_ADDRESS_ID) SHIP_TO_ADDRESS_ID,
NVL(A.SHIP_TO_NAME_EXT,
B.SHIP_TO_NAME_EXT) SHIP_TO_NAME,
NVL(A.INTRMD_SHIP_TO_ID,
B.INTRMD_SHIP_TO_ID) INTRMD_SHIP_TO_ID,
NVL(A.CUSTOMER_ITEM_ID,
B.CUSTOMER_ITEM_ID) CUSTOMER_ITEM_ID,
--mci.customer_item_desc customer_item_desc,
NVL(A.INVENTORY_ITEM_ID,
B.INVENTORY_ITEM_ID) INVENTORY_ITEM_ID,
NVL(A.ITEM_DETAIL_SUBTYPE,
B.ITEM_DETAIL_SUBTYPE) ITEM_DETAIL_SUBTYPE,
FND1.MEANING DETAIL_SUBTYPE,
NVL(A.UOM_CODE,
B.UOM_CODE) UOM_CODE,
NVL(A.CUST_PO_NUMBER,
B.CUST_PO_NUMBER) CUST_PO_NUMBER,
NVL(A.INDUSTRY_ATTRIBUTE1,
B.INDUSTRY_ATTRIBUTE1) CUST_RECORD_YEAR,
A.ITEM_DETAIL_QUANTITY,
A.ITEM_DETAIL_TYPE,
FND2.MEANING NEW_DETAIL_TYPE,
B.ITEM_DETAIL_QUANTITY,
B.ITEM_DETAIL_TYPE,
FND3.MEANING OLD_DETAIL_TYPE
FROM RLM_SCHEDULE_LINES_ALL A,
(SELECT * FROM RLM_SCHEDULE_LINES_ALL b_in
WHERE TRUNC(b_in.START_DATE_TIME) >=
(SELECT TRUNC(SCHED_HORIZON_START_DATE)
FROM RLM_SCHEDULE_HEADERS
WHERE HEADER_ID = :P_NEW_HEADER_ID)
AND HEADER_ID = (SELECT header_id
FROM apps.rlm_schedule_headers_all
WHERE header_id =
(SELECT MAX(rsha.header_id)
FROM apps.rlm_schedule_headers_all rsha,
apps.rlm_schedule_lines_all rsla
WHERE rsha.customer_id = :p_customer_id
AND rsha.schedule_type = :p_schedule_type
AND rsla.inventory_item_id = b_in.inventory_item_id ---
AND rsla.org_id = rsha.org_id
AND (((rsla.cust_po_number = b_in.cust_po_number)AND
EXISTS (SELECT 'x'
FROM FND_LOOKUP_VALUES_VL FLV,
RA_CUSTOMERS RC
WHERE FLV.LOOKUP_TYPE = 'TEST_RLM_CHECK_CUST'
AND FLV.MEANING = RC.CUSTOMER_NAME
AND RC.CUSTOMER_ID = :P_CUSTOMER_ID))
OR
NOT EXISTS (SELECT 'x'
FROM FND_LOOKUP_VALUES_VL FLV,
RA_CUSTOMERS RC
WHERE FLV.LOOKUP_TYPE = 'TEST_RLM_CHECK_CUST'
AND FLV.MEANING = RC.CUSTOMER_NAME
AND RC.CUSTOMER_ID = :P_CUSTOMER_ID) )---
and rsha.header_id = rsla.header_id
and rsla.ship_from_org_id = :p_ship_from_org_id
AND rsha.ece_tp_location_code_ext = :p_ece_tp_location_code_ext
AND NVL(rsha.header_ref_value_1, '1') =
NVL(rsha.header_ref_value_1, '1')
AND rsha.header_id NOT IN
(SELECT header_id
FROM apps.rlm_schedule_headers_all
WHERE attribute1 = :p_request_id)))) B,
--rlm_schedule_headers c,
-- hr_organization_units hrorg,
--mtl_customer_items mci,
FND_LOOKUPS FND1,
FND_LOOKUPS FND2,
FND_LOOKUPS FND3
-- ra_addresses_all radd2,
-- ra_site_uses_all rsu2
WHERE A.HEADER_ID = :P_NEW_HEADER_ID
---- AND B.HEADER_ID(+) = :P_OLD_HEADER_ID
--a.header_id=c.header_id and
-- a.header_id = 803 and
-- b.header_id (+) = 804 and
AND B.CUSTOMER_ITEM_ID(+) = A.CUSTOMER_ITEM_ID
AND B.SHIP_TO_ORG_ID(+) = A.SHIP_TO_ORG_ID
AND B.SHIP_FROM_ORG_ID(+) = A.SHIP_FROM_ORG_ID
AND B.INVENTORY_ITEM_ID(+) = A.INVENTORY_ITEM_ID
AND NVL(B.INTRMD_SHIP_TO_ID(+),
NVL(A.INTRMD_SHIP_TO_ID,
0)) = NVL(A.INTRMD_SHIP_TO_ID,
0)
AND B.ITEM_DETAIL_SUBTYPE(+) = A.ITEM_DETAIL_SUBTYPE
AND B.UOM_CODE(+) = A.UOM_CODE
AND NVL(B.CUST_PO_NUMBER(+),
NVL(A.CUST_PO_NUMBER,
0)) = NVL(A.CUST_PO_NUMBER,
0)
AND B.ITEM_DETAIL_TYPE(+) < :P_ITEM_DETAIL_TYPE
AND A.ITEM_DETAIL_TYPE < :P_ITEM_DETAIL_TYPE
AND TRUNC(B.START_DATE_TIME(+)) = TRUNC(A.START_DATE_TIME)
AND FND1.LOOKUP_CODE = NVL(B.ITEM_DETAIL_SUBTYPE,
A.ITEM_DETAIL_SUBTYPE)
AND FND1.LOOKUP_TYPE = :P_RLM_DETAIL_SUBTYPE_CODE
AND A.ITEM_DETAIL_TYPE = FND2.LOOKUP_CODE
AND FND2.LOOKUP_TYPE = :P_RLM_DETAIL_TYPE_CODE
AND NVL(B.ITEM_DETAIL_TYPE,
'0') = FND3.LOOKUP_CODE
AND A.SHIP_FROM_ORG_ID = :P_SHIP_FROM_ORG_ID
AND B.SHIP_FROM_ORG_ID(+) = :P_SHIP_FROM_ORG_ID
AND FND3.LOOKUP_TYPE = :P_RLM_DETAIL_TYPE_CODE
&P_WHERE5 &P_WHERE3
-- CHANGES
&P_WHERE_DATE_BThe above query is related to the Oracle Release Management 11.5.10.2
The main header table is RLM_SCHEDULE_HEADERS_ALL which contains the information like schedule_reference_number and other details. In one schedule there can be many item records for different dates which are stored in the child table RLM_SCHEDULE_LINES_ALL. Both the tables are linked with HEADER_ID. Each schedule in header table has one horizon start date and horizon end date. Customer used to send these schedules every day for each item because of there business needs.
The requirement is to create a query to calculate the Net Change between the two schedules (Between the new and old). All the item records from child table for new schedule will be printed but only those item records from old schedule will be printed where schedule date in child table is within the horizon start date and end date of new schedule.
There are following indexes on the table RLM_SCHEDULE_LINES_ALL
IDX$$_199350001 Normal INVENTORY_ITEM_ID, SHIP_TO_ORG_ID, SHIP_FROM_NAME_EXT
IDX$$_199350002 Normal HEADER_ID, INVENTORY_ITEM_ID
RLM_SCHEDULE_LINE_CUSTOM Normal ITEM_DETAIL_TYPE, HEADER_ID
RLM_SCHEDULE_LINE_N1 Normal HEADER_ID, INTERFACE_LINE_ID
RLM_SCHEDULE_LINE_N2 Normal SHIP_FROM_ORG_ID, SHIP_TO_ORG_ID, CUSTOMER_ITEM_ID
RLM_SCHEDULE_LINE_N99 Normal INVENTORY_ITEM_ID
RLM_SCHEDULE_LINE_U1 Normal LINE_ID
XXRLM_RLM_SCHEDULE_LINES Normal SHIP_TO_ORG_ID, SHIP_FROM_NAME_EXT, PROCESS_STATUS, ITEM_DETAIL_TYPE, INVENTORY_ITEM_ID, CUSTOMER_ITEM_ID
Database Version: 11.1.0.7.0Optimizer Parameters:
SQL> show parameter optimizer
NAME TYPE VALUE
_optimizer_push_pred_cost_based boolean TRUE
optimizer_capture_sql_plan_baselines boolean FALSE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 11.1.0.6
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean FALSE
optimizer_use_invisible_indexes boolean FALSE
optimizer_use_pending_statistics boolean FALSE
optimizer_use_sql_plan_baselines boolean TRUE
SQL>
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 8
SQL>
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
SQL>
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>
SQL> SELECT SNAME,
2 PNAME,
3 PVAL1,
4 PVAL2
5 FROM SYS.AUX_STATS$;
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 03-30-2011 06:20
SYSSTATS_INFO DSTOP 03-30-2011 06:20
SYSSTATS_INFO FLAGS 0
SYSSTATS_MAIN CPUSPEEDNW 976.063
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 SLAVETHR
13 rows selected
SQL>Output of the explain plan will be in the next thread because of size constraint.Here is the output of explain plan
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | R
| 0 | SELECT STATEMENT | |
| 1 | SORT UNIQUE | |
| 2 | UNION-ALL | |
|* 3 | FILTER | |
| 4 | NESTED LOOPS | |
| 5 | NESTED LOOPS | |
| 6 | NESTED LOOPS | |
|* 7 | HASH JOIN | |
| 8 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
|* 9 | INDEX SKIP SCAN | RLM_SCHEDULE_LINE_CUSTOM |
|* 10 | HASH JOIN RIGHT OUTER | |
|* 11 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
|* 12 | INDEX SKIP SCAN | RLM_SCHEDULE_LINE_CUSTOM |
| 13 | NESTED LOOPS | |
| 14 | NESTED LOOPS | |
| 15 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
PLAN_TABLE_OUTPUT
|* 16 | INDEX RANGE SCAN | IDX$$_123E00001 |
|* 17 | INDEX RANGE SCAN | RLM_SCHEDULE_LINE_CUSTOM |
|* 18 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
|* 19 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 20 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
|* 21 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 22 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
| 23 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
|* 24 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U1 |
|* 25 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U1 |
| 26 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
|* 27 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
| 28 | SORT AGGREGATE | |
| 29 | NESTED LOOPS | |
| 30 | NESTED LOOPS | |
| 31 | NESTED LOOPS ANTI | |
|* 32 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 33 | INDEX RANGE SCAN | RLM_SCHEDULE_HEADERS_N3 |
|* 34 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 35 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
|* 36 | INDEX RANGE SCAN | IDX$$_199350002 |
PLAN_TABLE_OUTPUT
|* 37 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
| 38 | NESTED LOOPS | |
| 39 | NESTED LOOPS | |
| 40 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS |
|* 41 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 |
| 42 | TABLE ACCESS BY INDEX ROWID | HZ_PARTIES | 5
|* 43 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 |
|* 44 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U2 |
| 45 | NESTED LOOPS | |
| 46 | NESTED LOOPS | |
| 47 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS |
|* 48 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 |
| 49 | TABLE ACCESS BY INDEX ROWID | HZ_PARTIES | 5
|* 50 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 |
|* 51 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U2 |
| 52 | NESTED LOOPS | |
| 53 | NESTED LOOPS | |
| 54 | NESTED LOOPS | |
| 55 | NESTED LOOPS OUTER | |
| 56 | NESTED LOOPS | |
| 57 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
PLAN_TABLE_OUTPUT
|* 58 | INDEX RANGE SCAN | IDX$$_123E00001 |
|* 59 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
|* 60 | INDEX RANGE SCAN | RLM_SCHEDULE_LINE_CUSTOM |
|* 61 | VIEW PUSHED PREDICATE | |
|* 62 | FILTER | |
|* 63 | FILTER | |
|* 64 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
|* 65 | INDEX RANGE SCAN | IDX$$_199350001 |
|* 66 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 67 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
|* 68 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
| 69 | SORT AGGREGATE | |
| 70 | NESTED LOOPS | |
| 71 | NESTED LOOPS | |
| 72 | NESTED LOOPS ANTI | |
|* 73 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 74 | INDEX RANGE SCAN | RLM_SCHEDULE_HEADERS_N3 |
|* 75 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 76 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
|* 77 | INDEX RANGE SCAN | IDX$$_199350002 |
|* 78 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
PLAN_TABLE_OUTPUT
| 79 | NESTED LOOPS | |
| 80 | NESTED LOOPS | |
| 81 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_ACCOUNTS |
|* 82 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 |
| 83 | TABLE ACCESS BY INDEX ROWID| HZ_PARTIES | 5
|* 84 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 |
|* 85 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U2 |
| 86 | NESTED LOOPS | |
| 87 | NESTED LOOPS | |
| 88 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_ACCOUNTS |
|* 89 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 |
| 90 | TABLE ACCESS BY INDEX ROWID| HZ_PARTIES | 5
|* 91 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 |
|* 92 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U2 |
| 93 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
|* 94 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U1 |
|* 95 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U1 |
| 96 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
3 - filter("HEADER_ID"= (SELECT "HEADER_ID" FROM "APPS"."RLM_SCHEDULE_HEADERS
"RLM_SCHEDULE_HEADERS_ALL" WHERE "HEADER_ID"= (SELECT MAX("RSHA"."
"APPS"."RLM_SCHEDULE_LINES_ALL" "RSLA","APPS"."RLM_SCHEDULE_HEADER
"RSHA","APPS"."RLM_SCHEDULE_HEADERS_ALL" "RLM_SCHEDULE_HEADERS_ALL
"RSHA"."HEADER_ID"="HEADER_ID" AND TO_NUMBER("ATTRIBUTE1")=1090072
"RSHA"."ECE_TP_LOCATION_CODE_EXT"='AG-60989' AND "RSHA"."CUSTOMER_
"RSHA"."SCHEDULE_TYPE"='PLANNING_RELEASE' AND NVL("RSHA"."HEADER_R
"RSLA"."INVENTORY_ITEM_ID"=:B1 AND "RSHA"."HEADER_ID"="RSLA"."HEAD
"RSLA"."SHIP_FROM_ORG_ID"=2904 AND ("RSLA"."CUST_PO_NUMBER"=:B2 AN
"AR"."HZ_CUST_ACCOUNTS" "CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APP
WHERE "B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=US
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
7 - access("B_IN"."CUSTOMER_ITEM_ID"="CUSTOMER_ITEM_ID")
9 - access("HEADER_ID"=1197995)
PLAN_TABLE_OUTPUT
filter("HEADER_ID"=1197995)
10 - access("A"."CUSTOMER_ITEM_ID"(+)="B_IN"."CUSTOMER_ITEM_ID" AND
"A"."SHIP_TO_ORG_ID"(+)="B_IN"."SHIP_TO_ORG_ID" AND
"A"."SHIP_FROM_ORG_ID"(+)="B_IN"."SHIP_FROM_ORG_ID" AND
"A"."INVENTORY_ITEM_ID"(+)="B_IN"."INVENTORY_ITEM_ID" AND
"A"."ITEM_DETAIL_SUBTYPE"(+)="B_IN"."ITEM_DETAIL_SUBTYPE" AND "A".
AND TRUNC(INTERNAL_FUNCTION("A"."START_DATE_TIME"(+)))=TRUNC(INTER
IME")))
filter(NVL("A"."INTRMD_SHIP_TO_ID"(+),NVL("B_IN"."INTRMD_SHIP_TO_ID",0))=
SHIP_TO_ID",0) AND NVL("A"."CUST_PO_NUMBER"(+),NVL("B_IN"."CUST_PO
O_NUMBER",'0'))
11 - filter("A"."SHIP_FROM_ORG_ID"(+)=2904)
12 - access("A"."HEADER_ID"(+)=1197995)
filter("A"."HEADER_ID"(+)=1197995 AND TO_NUMBER("A"."ITEM_DETAIL_TYPE"(+)
16 - access("LOOKUP_TYPE"='RLM_DETAIL_TYPE_CODE' AND "VIEW_APPLICATION_ID"=0 A
"LANGUAGE"=USERENV('LANG'))
filter("SECURITY_GROUP_ID"="FND_GLOBAL"."LOOKUP_SECURITY_GROUP"("LV"."LOO
W_APPLICATION_ID"))
17 - access("LOOKUP_CODE"="B_IN"."ITEM_DETAIL_TYPE")
filter(TO_NUMBER("B_IN"."ITEM_DETAIL_TYPE")<3)
18 - filter("B_IN"."SHIP_FROM_ORG_ID"=2904 AND TRUNC(INTERNAL_FUNCTION("B_IN".
PLAN_TABLE_OUTPUT
>= (SELECT TRUNC(INTERNAL_FUNCTION("SCHED_HORIZON_START_DATE")) FR
"RLM"."RLM_SCHEDULE_HEADERS_ALL" "RLM_SCHEDULE_HEADERS_ALL" WHERE
NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
TRUNC(INTERNAL_FUNCTION("B_IN"."START_DATE_TIME"))<= (SELECT
TRUNC(INTERNAL_FUNCTION("SCHED_HORIZON_END_DATE")) FROM "RLM"."RLM
"RLM_SCHEDULE_HEADERS_ALL" WHERE "HEADER_ID"=1197995 AND
NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
19 - filter(NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
20 - access("HEADER_ID"=1197995)
21 - filter(NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
22 - access("HEADER_ID"=1197995)
24 - access("LOOKUP_TYPE"='RLM_DETAIL_SUBTYPE_CODE' AND "VIEW_APPLICATION_ID"=
"LOOKUP_CODE"=NVL("A"."ITEM_DETAIL_SUBTYPE","B_IN"."ITEM_DETAIL_SU
PLAN_TABLE_OUTPUT
"LANGUAGE"=USERENV('LANG'))
filter("LANGUAGE"=USERENV('LANG') AND "SECURITY_GROUP_ID"="FND_GLOBAL"."L
P"("LV"."LOOKUP_TYPE","LV"."VIEW_APPLICATION_ID"))
25 - access("LOOKUP_TYPE"='RLM_DETAIL_TYPE_CODE' AND "VIEW_APPLICATION_ID"=0 A
"LOOKUP_CODE"=NVL("A"."ITEM_DETAIL_TYPE",'0') AND "LANGUAGE"=USERE
filter("LANGUAGE"=USERENV('LANG') AND "SECURITY_GROUP_ID"="FND_GLOBAL"."L
P"("LV"."LOOKUP_TYPE","LV"."VIEW_APPLICATION_ID"))
27 - access("HEADER_ID"= (SELECT MAX("RSHA"."HEADER_ID") FROM "APPS"."RLM_SCHE
"RSLA","APPS"."RLM_SCHEDULE_HEADERS_ALL" "RSHA","APPS"."RLM_SCHEDU
"RLM_SCHEDULE_HEADERS_ALL" WHERE "RSHA"."HEADER_ID"="HEADER_ID" AN
TO_NUMBER("ATTRIBUTE1")=109007290 AND "RSHA"."ECE_TP_LOCATION_CODE
"RSHA"."CUSTOMER_ID"=64742 AND "RSHA"."SCHEDULE_TYPE"='PLANNING_RE
NVL("RSHA"."HEADER_REF_VALUE_1",'1') IS NOT NULL AND "RSLA"."INVEN
"RSHA"."HEADER_ID"="RSLA"."HEADER_ID" AND "RSLA"."SHIP_FROM_ORG_ID
("RSLA"."CUST_PO_NUMBER"=:B2 AND EXISTS (SELECT 0 FROM "AR"."HZ_C
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
PLAN_TABLE_OUTPUT
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
32 - filter("RSHA"."CUSTOMER_ID"=64742 AND "RSHA"."SCHEDULE_TYPE"='PLANNING_RE
NVL("RSHA"."HEADER_REF_VALUE_1",'1') IS NOT NULL)
33 - access("RSHA"."ECE_TP_LOCATION_CODE_EXT"='AG-60989')
34 - filter(TO_NUMBER("ATTRIBUTE1")=109007290)
35 - access("RSHA"."HEADER_ID"="HEADER_ID")
36 - access("RSHA"."HEADER_ID"="RSLA"."HEADER_ID" AND "RSLA"."INVENTORY_ITEM_I
37 - filter("RSLA"."SHIP_FROM_ORG_ID"=2904 AND ("RSLA"."CUST_PO_NUMBER"=:B1 AN
0 FROM "AR"."HZ_CUST_ACCOUNTS" "CUST_ACCT","AR"."HZ_PARTIES" "PART
"B" WHERE "B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
41 - access("CUST_ACCT"."CUST_ACCOUNT_ID"=64742)
43 - access("CUST_ACCT"."PARTY_ID"="PARTY"."PARTY_ID")
44 - access("B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."MEANING"=SUBSTRB("
AND "B"."LANGUAGE"=USERENV('LANG'))
PLAN_TABLE_OUTPUT
filter("B"."LANGUAGE"=USERENV('LANG') AND "B"."MEANING"=SUBSTRB("PARTY_NA
48 - access("CUST_ACCT"."CUST_ACCOUNT_ID"=64742)
50 - access("CUST_ACCT"."PARTY_ID"="PARTY"."PARTY_ID")
51 - access("B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."MEANING"=SUBSTRB("
AND "B"."LANGUAGE"=USERENV('LANG'))
filter("B"."LANGUAGE"=USERENV('LANG') AND "B"."MEANING"=SUBSTRB("PARTY_NA
58 - access("LOOKUP_TYPE"='RLM_DETAIL_TYPE_CODE' AND "VIEW_APPLICATION_ID"=0 A
"LANGUAGE"=USERENV('LANG'))
filter("SECURITY_GROUP_ID"="FND_GLOBAL"."LOOKUP_SECURITY_GROUP"("LV"."LOO
W_APPLICATION_ID"))
59 - filter("A"."SHIP_FROM_ORG_ID"=2904)
60 - access("A"."ITEM_DETAIL_TYPE"="LOOKUP_CODE" AND "A"."HEADER_ID"=1197995)
filter(TO_NUMBER("A"."ITEM_DETAIL_TYPE")<3)
61 - filter(NVL("B"."INTRMD_SHIP_TO_ID"(+),NVL("A"."INTRMD_SHIP_TO_ID",0))=NVL
O_ID",0) AND "B"."ITEM_DETAIL_SUBTYPE"(+)="A"."ITEM_DETAIL_SUBTYPE
"B"."UOM_CODE"(+)="A"."UOM_CODE" AND NVL("B"."CUST_PO_NUMBER"(+),N
("A"."CUST_PO_NUMBER",'0') AND TRUNC(INTERNAL_FUNCTION("B"."START_
NCTION("A"."START_DATE_TIME")))
62 - filter("HEADER_ID"= (SELECT "HEADER_ID" FROM "APPS"."RLM_SCHEDULE_HEADERS
"RLM_SCHEDULE_HEADERS_ALL" WHERE "HEADER_ID"= (SELECT MAX("RSHA"."
"APPS"."RLM_SCHEDULE_LINES_ALL" "RSLA","APPS"."RLM_SCHEDULE_HEADER
PLAN_TABLE_OUTPUT
"RSHA","APPS"."RLM_SCHEDULE_HEADERS_ALL" "RLM_SCHEDULE_HEADERS_ALL
"RSHA"."HEADER_ID"="HEADER_ID" AND TO_NUMBER("ATTRIBUTE1")=1090072
"RSHA"."ECE_TP_LOCATION_CODE_EXT"='AG-60989' AND "RSHA"."CUSTOMER_
"RSHA"."SCHEDULE_TYPE"='PLANNING_RELEASE' AND NVL("RSHA"."HEADER_R
"RSLA"."INVENTORY_ITEM_ID"=:B1 AND "RSHA"."HEADER_ID"="RSLA"."HEAD
"RSLA"."SHIP_FROM_ORG_ID"=2904 AND ("RSLA"."CUST_PO_NUMBER"=:B2 AN
"AR"."HZ_CUST_ACCOUNTS" "CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APP
WHERE "B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=US
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
63 - filter("A"."SHIP_FROM_ORG_ID"=2904)
64 - filter("B_IN"."CUSTOMER_ITEM_ID"="A"."CUSTOMER_ITEM_ID" AND
"B_IN"."SHIP_FROM_ORG_ID"="A"."SHIP_FROM_ORG_ID" AND TO_NUMBER("B_
TRUNC(INTERNAL_FUNCTION("B_IN"."START_DATE_TIME"))>= (SELECT
TRUNC(INTERNAL_FUNCTION("SCHED_HORIZON_START_DATE")) FROM "RLM"."R
"RLM_SCHEDULE_HEADERS_ALL" WHERE "HEADER_ID"=1197995 AND
NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
PLAN_TABLE_OUTPUT
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
65 - access("B_IN"."INVENTORY_ITEM_ID"="A"."INVENTORY_ITEM_ID" AND
"B_IN"."SHIP_TO_ORG_ID"="A"."SHIP_TO_ORG_ID")
66 - filter(NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
67 - access("HEADER_ID"=1197995)
68 - access("HEADER_ID"= (SELECT MAX("RSHA"."HEADER_ID") FROM "APPS"."RLM_SCHE
"RSLA","APPS"."RLM_SCHEDULE_HEADERS_ALL" "RSHA","APPS"."RLM_SCHEDU
"RLM_SCHEDULE_HEADERS_ALL" WHERE "RSHA"."HEADER_ID"="HEADER_ID" AN
TO_NUMBER("ATTRIBUTE1")=109007290 AND "RSHA"."ECE_TP_LOCATION_CODE
"RSHA"."CUSTOMER_ID"=64742 AND "RSHA"."SCHEDULE_TYPE"='PLANNING_RE
NVL("RSHA"."HEADER_REF_VALUE_1",'1') IS NOT NULL AND "RSLA"."INVEN
"RSHA"."HEADER_ID"="RSLA"."HEADER_ID" AND "RSLA"."SHIP_FROM_ORG_ID
("RSLA"."CUST_PO_NUMBER"=:B2 AND EXISTS (SELECT 0 FROM "AR"."HZ_C
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
PLAN_TABLE_OUTPUT
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
73 - filter("RSHA"."CUSTOMER_ID"=64742 AND "RSHA"."SCHEDULE_TYPE"='PLANNING_RE
NVL("RSHA"."HEADER_REF_VALUE_1",'1') IS NOT NULL)
74 - access("RSHA"."ECE_TP_LOCATION_CODE_EXT"='AG-60989')
75 - filter(TO_NUMBER("ATTRIBUTE1")=109007290)
76 - access("RSHA"."HEADER_ID"="HEADER_ID")
77 - access("RSHA"."HEADER_ID"="RSLA"."HEADER_ID" AND "RSLA"."INVENTORY_ITEM_I
78 - filter("RSLA"."SHIP_FROM_ORG_ID"=2904 AND ("RSLA"."CUST_PO_NUMBER"=:B1 AN
0 FROM "AR"."HZ_CUST_ACCOUNTS" "CUST_ACCT","AR"."HZ_PARTIES" "PART
"B" WHERE "B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
82 - access("CUST_ACCT"."CUST_ACCOUNT_ID"=64742)
84 - access("CUST_ACCT"."PARTY_ID"="PARTY"."PARTY_ID")
85 - access("B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."MEANING"=SUBSTRB("
PLAN_TABLE_OUTPUT
AND "B"."LANGUAGE"=USERENV('LANG'))
filter("B"."LANGUAGE"=USERENV('LANG') AND "B"."MEANING"=SUBSTRB("PARTY_NA
89 - access("CUST_ACCT"."CUST_ACCOUNT_ID"=64742)
91 - access("CUST_ACCT"."PARTY_ID"="PARTY"."PARTY_ID")
92 - access("B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."MEANING"=SUBSTRB("
AND "B"."LANGUAGE"=USERENV('LANG'))
filter("B"."LANGUAGE"=USERENV('LANG') AND "B"."MEANING"=SUBSTRB("PARTY_NA
94 - access("LOOKUP_TYPE"='RLM_DETAIL_SUBTYPE_CODE' AND "VIEW_APPLICATION_ID"=
"LOOKUP_CODE"=NVL("B"."ITEM_DETAIL_SUBTYPE","A"."ITEM_DETAIL_SUBTY
"LANGUAGE"=USERENV('LANG'))
filter("LANGUAGE"=USERENV('LANG') AND "SECURITY_GROUP_ID"="FND_GLOBAL"."L
P"("LV"."LOOKUP_TYPE","LV"."VIEW_APPLICATION_ID"))
95 - access("LOOKUP_TYPE"='RLM_DETAIL_TYPE_CODE' AND "VIEW_APPLICATION_ID"=0 A
"LOOKUP_CODE"=NVL("B"."ITEM_DETAIL_TYPE",'0') AND "LANGUAGE"=USERE
filter("LANGUAGE"=USERENV('LANG') AND "SECURITY_GROUP_ID"="FND_GLOBAL"."L
P"("LV"."LOOKUP_TYPE","LV"."VIEW_APPLICATION_ID"))
Note
- 'PLAN_TABLE' is old version
313 rows selectedPlease suggest me how can I work on the query part to improve the performance.
Thanks
Vishalaksha -
Need help writing Performance Management Report
Hi Experts
I need some help retrieving specific Performance Management data for a report.
I have the employee pernr.
1. From this I need to determine which teams the employee belonged to for the period 1 Oct - 31 Sept.
2. What was the total performance score for the TEAM for that same period.
Can someone please help me out. The table data seems to be quite complex.
Thannks in advance
Anton Kruse
Moderator Message: Specs-dumping is not allowed. Please get back if you have a specific question
Edited by: kishan P on Mar 7, 2012 5:10 PMHi Arnold,
I think the solution provided by Vadim is the only way and it's working.
Shrikant -
Hi Gurus,
I m new to the group and SAP BW as well,so i need ur valuable inputs for a Performance related Project.
I m going to start a new project in a wks time so and i m working as a Performance Tuning Consultant on that(Load & Query Performance),but i don't have any idea about this,so i need ur valuable advice on that,plz.
Can anyone plz suggest me the possible ways of suggestions so that i can tell the client as a gud consultant to start with but these days i m going though BW Performance & Authorization(BW360) which is really helpful for me but apart from that i need ur valuable inputs as well.
Thanks in Advance.
regards
Amithi Amit,
check this.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/afbad390-0201-0010-daa4-9ef0168d41b6
also
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/media/uuid/10b589ad-0701-0010-0299-e5c282b7aaad
regards. -
Need help with performance & memory tuning in a data warehousing environment
Dear All,
Good Day.
We had successfully migrated from a 4 node half-rack V2 Exadata to a 2 node quarter rack X4-2 Exadata. However, we are facing some issues with performance only for few loads while others have in fact shown good improvement.
1. The total memory on the OS is 250GB for each node (two compute nodes for a quarter rack).
2. Would be grateful if someone could help me with the best equation to calculate the SGA and PGA ( and also in allocation of shared_pool, large_pool etc) or whether Automatic Memory Management is advisable?
3. We had run exachk report which suggested us to configure huge pages.
4. When we tried to increase the SGA to more than 30GB the system doesn't allow us to do so. We had however set the PGA to 85GB.
5. Also, we had observed that some of the queries involving joins and indexes are taking longer time.
Any advise would be greatly appreciated.
Warm Regards,
Vikram.Hi Vikram,
There is no formula about SGA and PGA, but the best practices for OLTP environments is for a give ammount of memory (which cannot be up to 80% of total RAM from server) you should make 80% to SGA and 20% to PGA. For Data Warehouse envs, the values are like 60% SGA and 40% PGA or it can be up to 50%-50%. Also, some docs disencourage you to keep the database in Automatic Memory Management when you are using a big SGA (> 10G).
As you are using a RAC environment, you should configure Huge Pages. And if the systems are not allowing you to increase memory, just take a look at the semaphore parameters, probably they are set lower values. And for the poor performance queries, we need to see explain plans, table structure and you would also analyze if smart scan is playing the game.
Regards. -
Need help on performance of this sql
Hi,
I have 2million records in my table, now i need to add one new column and have to update records into this column using sequence.
Ex. update table_name
set new_column = sequ_name.nextval
where col1 = batch_id;
My question is, if i update like this for the batch_id(same id for 1.5million records), will it affect the performace. or is it any other best way to achieve this...
kindly help..
Regards,
NagWe had a similar project and in test it took several hours to run. When I upped the sequence cache to 5000 it completed in less than a 10th of the time. Worth trialling different values for the sequence cache, as I suspect there are diminishing returns as it gets larger (setting the cache size to 1.5 million would probably not be a good idea).
-
hallow
i doing this select and it take more then 10 minutes and i don't now way because
object_key have just 60 entries ?
how i can slve this problem?
Regards
SELECT * FROM covp APPENDING TABLE *covp
FOR ALL ENTRIES IN object_key
WHERE kokrs EQ '1000'
AND objnr EQ object_key-objnr
AND budat IN so_budat
AND stflg EQ space .Ways of Performance Tuning
1. Selection Criteria
2. Select Statements
Select Queries
SQL Interface
Aggregate Functions
For all Entries
Select Over more than one internal table
Selection Criteria
1. Restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code using CHECK statement.
2. Select with selection list.
SELECT * FROM SBOOK INTO SBOOK_WA.
CHECK: SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
ENDSELECT.
The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list
SELECT CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
WHERE SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
Select Statements Select Queries
1. Avoid nested selects
SELECT * FROM EKKO INTO EKKO_WA.
SELECT * FROM EKAN INTO EKAN_WA
WHERE EBELN = EKKO_WA-EBELN.
ENDSELECT.
ENDSELECT.
The above code can be much more optimized by the code written below.
SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
FROM EKKO AS P INNER JOIN EKAN AS F
ON PEBELN = FEBELN.
Note: A simple SELECT loop is a single database access whose result is passed to the ABAP program line by line. Nested SELECT loops mean that the number of accesses in the inner loop is multiplied by the number of accesses in the outer loop. One should therefore use nested SELECT loops only if the selection in the outer loop contains very few lines or the outer loop is a SELECT SINGLE statement.
2. Select all the records in a single shot using into table clause of select statement rather than to use Append statements.
SELECT * FROM SBOOK INTO SBOOK_WA.
CHECK: SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
ENDSELECT.
The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list and puts the data in one shot using into table
SELECT CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
WHERE SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
3. When a base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index.
To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields. In certain scenarios, it is advisable to check whether a new index can speed up the performance of a program. This will come handy in programs that access data from the finance tables.
4. For testing existence, use Select.. Up to 1 rows statement instead of a Select-Endselect-loop with an Exit.
SELECT * FROM SBOOK INTO SBOOK_WA
UP TO 1 ROWS
WHERE CARRID = 'LH'.
ENDSELECT.
The above code is more optimized as compared to the code mentioned below for testing existence of a record.
SELECT * FROM SBOOK INTO SBOOK_WA
WHERE CARRID = 'LH'.
EXIT.
ENDSELECT.
5. Use Select Single if all primary key fields are supplied in the Where condition .
If all primary key fields are supplied in the Where conditions you can even use Select Single.
Select Single requires one communication with the database system, whereas Select-Endselect needs two.
Select Statements SQL Interface
1. Use column updates instead of single-row updates
to update your database tables.
SELECT * FROM SFLIGHT INTO SFLIGHT_WA.
SFLIGHT_WA-SEATSOCC =
SFLIGHT_WA-SEATSOCC - 1.
UPDATE SFLIGHT FROM SFLIGHT_WA.
ENDSELECT.
The above mentioned code can be more optimized by using the following code
UPDATE SFLIGHT
SET SEATSOCC = SEATSOCC - 1.
2. For all frequently used Select statements, try to use an index.
SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
WHERE CARRID = 'LH'
AND CONNID = '0400'.
ENDSELECT.
The above mentioned code can be more optimized by using the following code
SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
WHERE MANDT IN ( SELECT MANDT FROM T000 )
AND CARRID = 'LH'
AND CONNID = '0400'.
ENDSELECT.
3. Using buffered tables improves the performance considerably.
Bypassing the buffer increases the network considerably
SELECT SINGLE * FROM T100 INTO T100_WA
BYPASSING BUFFER
WHERE SPRSL = 'D'
AND ARBGB = '00'
AND MSGNR = '999'.
The above mentioned code can be more optimized by using the following code
SELECT SINGLE * FROM T100 INTO T100_WA
WHERE SPRSL = 'D'
AND ARBGB = '00'
AND MSGNR = '999'.
Select Statements Aggregate Functions
If you want to find the maximum, minimum, sum and average value or the count of a database column, use a select list with aggregate functions instead of computing the aggregates yourself.
Some of the Aggregate functions allowed in SAP are MAX, MIN, AVG, SUM, COUNT, COUNT( * )
Consider the following extract.
Maxno = 0.
Select * from zflight where airln = LF and cntry = IN.
Check zflight-fligh > maxno.
Maxno = zflight-fligh.
Endselect.
The above mentioned code can be much more optimized by using the following code.
Select max( fligh ) from zflight into maxno where airln = LF and cntry = IN.
Select Statements For All Entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Points to be must considered FOR ALL ENTRIES
Check that data is present in the driver table
Sorting the driver table
Removing duplicates from the driver table
Consider the following piece of extract
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
The above mentioned can be more optimized by using the following code.
Sort int_cntry by cntry.
Delete adjacent duplicates from int_cntry.
If NOT int_cntry[] is INITIAL.
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
Endif.
Select Statements Select Over more than one Internal table
1. Its better to use a views instead of nested Select statements.
SELECT * FROM DD01L INTO DD01L_WA
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
SELECT SINGLE * FROM DD01T INTO DD01T_WA
WHERE DOMNAME = DD01L_WA-DOMNAME
AND AS4LOCAL = 'A'
AND AS4VERS = DD01L_WA-AS4VERS
AND DDLANGUAGE = SY-LANGU.
ENDSELECT.
The above code can be more optimized by extracting all the data from view DD01V_WA
SELECT * FROM DD01V INTO DD01V_WA
WHERE DOMNAME LIKE 'CHAR%'
AND DDLANGUAGE = SY-LANGU.
ENDSELECT
2. To read data from several logically connected tables use a join instead of nested Select statements. Joins are preferred only if all the primary key are available in WHERE clause for the tables that are joined. If the primary keys are not provided in join the Joining of tables itself takes time.
SELECT * FROM EKKO INTO EKKO_WA.
SELECT * FROM EKAN INTO EKAN_WA
WHERE EBELN = EKKO_WA-EBELN.
ENDSELECT.
ENDSELECT.
The above code can be much more optimized by the code written below.
SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
FROM EKKO AS P INNER JOIN EKAN AS F
ON PEBELN = FEBELN.
3. Instead of using nested Select loops it is often better to use subqueries.
SELECT * FROM SPFLI
INTO TABLE T_SPFLI
WHERE CITYFROM = 'FRANKFURT'
AND CITYTO = 'NEW YORK'.
SELECT * FROM SFLIGHT AS F
INTO SFLIGHT_WA
FOR ALL ENTRIES IN T_SPFLI
WHERE SEATSOCC < F~SEATSMAX
AND CARRID = T_SPFLI-CARRID
AND CONNID = T_SPFLI-CONNID
AND FLDATE BETWEEN '19990101' AND '19990331'.
ENDSELECT.
The above mentioned code can be even more optimized by using subqueries instead of for all entries.
SELECT * FROM SFLIGHT AS F INTO SFLIGHT_WA
WHERE SEATSOCC < F~SEATSMAX
AND EXISTS ( SELECT * FROM SPFLI
WHERE CARRID = F~CARRID
AND CONNID = F~CONNID
AND CITYFROM = 'FRANKFURT'
AND CITYTO = 'NEW YORK' )
AND FLDATE BETWEEN '19990101' AND '19990331'.
ENDSELECT.
1. Table operations should be done using explicit work areas rather than via header lines.
READ TABLE ITAB INTO WA WITH KEY K = 'X BINARY SEARCH.
IS MUCH FASTER THAN USING
READ TABLE ITAB INTO WA WITH KEY K = 'X'.
If TAB has n entries, linear search runs in O( n ) time, whereas binary search takes only O( log2( n ) ).
2. Always try to use binary search instead of linear search. But dont forget to sort your internal table before that.
READ TABLE ITAB INTO WA WITH KEY K = 'X'. IS FASTER THAN USING
READ TABLE ITAB INTO WA WITH KEY (NAME) = 'X'.
3. A dynamic key access is slower than a static one, since the key specification must be evaluated at runtime.
4. A binary search using secondary index takes considerably less time.
5. LOOP ... WHERE is faster than LOOP/CHECK because LOOP ... WHERE evaluates the specified condition internally.
LOOP AT ITAB INTO WA WHERE K = 'X'.
ENDLOOP.
The above code is much faster than using
LOOP AT ITAB INTO WA.
CHECK WA-K = 'X'.
ENDLOOP.
6. Modifying selected components using MODIFY itab TRANSPORTING f1 f2.. accelerates the task of updating a line of an internal table.
WA-DATE = SY-DATUM.
MODIFY ITAB FROM WA INDEX 1 TRANSPORTING DATE.
The above code is more optimized as compared to
WA-DATE = SY-DATUM.
MODIFY ITAB FROM WA INDEX 1.
7. Accessing the table entries directly in a "LOOP ... ASSIGNING ..." accelerates the task of updating a set of lines of an internal table considerably
Modifying selected components only makes the program faster as compared to Modifying all lines completely.
e.g,
LOOP AT ITAB ASSIGNING <WA>.
I = SY-TABIX MOD 2.
IF I = 0.
<WA>-FLAG = 'X'.
ENDIF.
ENDLOOP.
The above code works faster as compared to
LOOP AT ITAB INTO WA.
I = SY-TABIX MOD 2.
IF I = 0.
WA-FLAG = 'X'.
MODIFY ITAB FROM WA.
ENDIF.
ENDLOOP.
8. If collect semantics is required, it is always better to use to COLLECT rather than READ BINARY and then ADD.
LOOP AT ITAB1 INTO WA1.
READ TABLE ITAB2 INTO WA2 WITH KEY K = WA1-K BINARY SEARCH.
IF SY-SUBRC = 0.
ADD: WA1-VAL1 TO WA2-VAL1,
WA1-VAL2 TO WA2-VAL2.
MODIFY ITAB2 FROM WA2 INDEX SY-TABIX TRANSPORTING VAL1 VAL2.
ELSE.
INSERT WA1 INTO ITAB2 INDEX SY-TABIX.
ENDIF.
ENDLOOP.
The above code uses BINARY SEARCH for collect semantics. READ BINARY runs in O( log2(n) ) time. The above piece of code can be more optimized by
LOOP AT ITAB1 INTO WA.
COLLECT WA INTO ITAB2.
ENDLOOP.
SORT ITAB2 BY K.
COLLECT, however, uses a hash algorithm and is therefore independent
of the number of entries (i.e. O(1)) .
9. "APPEND LINES OF itab1 TO itab2" accelerates the task of appending a table to another table considerably as compared to LOOP-APPEND-ENDLOOP.
APPEND LINES OF ITAB1 TO ITAB2.
This is more optimized as compared to
LOOP AT ITAB1 INTO WA.
APPEND WA TO ITAB2.
ENDLOOP.
10. DELETE ADJACENT DUPLICATES accelerates the task of deleting duplicate entries considerably as compared to READ-LOOP-DELETE-ENDLOOP.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING K.
This is much more optimized as compared to
READ TABLE ITAB INDEX 1 INTO PREV_LINE.
LOOP AT ITAB FROM 2 INTO WA.
IF WA = PREV_LINE.
DELETE ITAB.
ELSE.
PREV_LINE = WA.
ENDIF.
ENDLOOP.
11. "DELETE itab FROM ... TO ..." accelerates the task of deleting a sequence of lines considerably as compared to DO -DELETE-ENDDO.
DELETE ITAB FROM 450 TO 550.
This is much more optimized as compared to
DO 101 TIMES.
DELETE ITAB INDEX 450.
ENDDO.
12. Copying internal tables by using ITAB2[ ] = ITAB1[ ] as compared to LOOP-APPEND-ENDLOOP.
ITAB2[] = ITAB1[].
This is much more optimized as compared to
REFRESH ITAB2.
LOOP AT ITAB1 INTO WA.
APPEND WA TO ITAB2.
ENDLOOP.
13. Specify the sort key as restrictively as possible to run the program faster.
SORT ITAB BY K. makes the program runs faster as compared to SORT ITAB.
Internal Tables contd
Hashed and Sorted tables
1. For single read access hashed tables are more optimized as compared to sorted tables.
2. For partial sequential access sorted tables are more optimized as compared to hashed tables
Hashed And Sorted Tables
Point # 1
Consider the following example where HTAB is a hashed table and STAB is a sorted table
DO 250 TIMES.
N = 4 * SY-INDEX.
READ TABLE HTAB INTO WA WITH TABLE KEY K = N.
IF SY-SUBRC = 0.
ENDIF.
ENDDO.
This runs faster for single read access as compared to the following same code for sorted table
DO 250 TIMES.
N = 4 * SY-INDEX.
READ TABLE STAB INTO WA WITH TABLE KEY K = N.
IF SY-SUBRC = 0.
ENDIF.
ENDDO.
Point # 2
Similarly for Partial Sequential access the STAB runs faster as compared to HTAB
LOOP AT STAB INTO WA WHERE K = SUBKEY.
ENDLOOP.
This runs faster as compared to
LOOP AT HTAB INTO WA WHERE K = SUBKEY.
ENDLOOP. -
Need help in Performance tuning
Hi All,
I am facing some performance issues in my program. The program taking a hell lot of time to execute and some times timing out without giving the out put. This is a report program with ALV output. It is handling mainly Sales related data.
The program is fetching a huge volume of data from different tables and processing this bulk data inside the loops several times. In most of the queries I am unable to supply all key fields, because my requirement is like that only. I have many places in my program i am using inner loop and function modules inside loop etc.
Any pointers on this will be a great help.
Regards,
Jijeesh P G1) Make sure that any READ or LOOP inside an outer LOOP accesses the inner table with an appropriate key (either using BINARY search when reading a standard table or using sorted/hashed tables for inner tables only). This helps in most cases.
2) If the tables witdh is more than aprox. 30 bytes LOOP ASSIGNING <wa> may help a bit. Declare <wa> for each table separately using the tables line type (otherway type casting would cost some additional time).
3) You may use FM SAPGUI_PROGRESS_INDICATOR in the outer loops to inform the user while he is waiting.
4) A COMMIT from time to time will reset the measured time for timeout ( and therefore avoids timeouts - do NOT use without checking step 1) ).
4) The programm may use virtual memory if a huge amount of data is selected ( I have seen dumps in due to the fact that nor more disk space was available). So - if STEPS 1)-3) failed - look a the process for rollling in/out). -
SLOW Query ... Need help improving performance
Database: Oracle 8i
Note: I don't have a whole lot of experience with writing queries, so please forgive me for any dumb mistakes I most likely made.
I have a query in which I have a SUM in two levels. I think this is probably the root cause of the very slow performance of the query. However, I just don't see any way around it, and can't come up with any other ways to speed up the query. The query itself only returns one line, the summary line. And, by slow, I mean it can take up to an hour or two. This is a query I need to run multiple times, based on some parameters that I cannot query from a database.
The query basically calculates the current unit cost of a part. It has to sum up the issue cost of the part (cost of material issued to the part's order), the actual dollars put into a part (labor, etc.), and the burden dollars associated with the part. This sum has to be divided by the total quantity of parts completed on the part's order to get the unit cost. I have to account for the possibility that the quantity complete is 0, so that I don't end up dividing by 0.
Below is my query, and sample data for it:
SELECT a.part_nbr
, a.mo_nbr
, a.unit_iss_cost
, CASE
WHEN a.qty_complete_ind ='Nonzero'
THEN SUM(a.act_dlrs/a.qty_complete)
ELSE 0
END AS unit_dlrs
, CASE
WHEN a.qty_complete_ind ='Zero'
THEN SUM(a.act_dlrs)
ELSE 0
END AS qty_0_dlrs
FROM ( SELECT act.part_nbr AS part_nbr
, act.order_nbr || '-' || act.sub_order_nbr AS mo_nbr
, ic.unit_iss_cost AS unit_iss_cost
, SUM (
act.act_dlrs_earned +
act.act_brdn_dls_earned +
act.tool_dlrs_earned +
act.act_fix_brdn_dls_ea
) AS act_dlrs
, ord.qty_complete AS qty_complete
, CASE
WHEN ord.qty_complete <>0
THEN 'Nonzero'
ELSE 'Zero'
END AS qty_complete_ind
FROM ACT act
, ISSUE_COST ic
, ORD ord
WHERE ord.ord_nbr =act.order_nbr AND
ord.sub_ord_nbr =act.sub_order_nbr AND
ord.major_seq_nbr =act.maj_seq_nbr AND
ic.ord_nbr =act.order_nbr AND
ic.sub_ord_nbr =act.sub_order_nbr AND
(act.order_nbr =LPAD(?,10,'0')) AND
(act.sub_order_nbr =LPAD(?,3,'0')) AND
(act.activity_date <=?)
GROUP BY act.part_nbr
, act.order_nbr || '-' || act.sub_order_nbr
, act.maj_seq_nbr
, ord.qty_complete
, ic.unit_iss_cost
) a
GROUP BY a.part_nbr
, a.mo_nbr
, a.unit_iss_cost
, a.qty_complete_ind
CREATE TABLE ACT
creation_date date
, c_id number (5,0)
, part_nbr varchar(25)
, order_nbr varchar(10)
, sub_order_nbr varchar(3)
, maj_seq_nbr varchar(4)
, act_dlrs_earned number (15,2)
, act_brdn_dls_earned number (15,2)
, tool_dlrs_earned number (15,2)
, act_fix_brdn_dls_ea number (15,2)
, activity_date date
CONSTRAINT ACT_PK
PRIMARY KEY (creation_date, c_id)
);--Please note, issue_cost is actually a view, not a table, but by itself it runs very quickly
CREATE TABLE ISSUE_COST
unit_iss_cost number(15,2)
, ord_nbr varchar(10)
, sub_ord_nbr varchar(3)
);--Please note, ord table has a couple of foreign keys that I did not mention
CREATE TABLE ORD
ord_nbr varchar(10)
, sub_ord_nbr varchar(3)
, major_seq_nbr varchar(4)
, qty_complete number (13,4)
);Sample tables:
ACT
creation_date c_id part_nbr order_nbr sub_order_nbr maj_seq_nbr act_dlrs_earned act_brdn_dls_earned tool_dlrs_earned act_fix_brdn_dls_ea activity_date
01/02/2000 12345 ABC-123 0000012345 001 0010 10.00 20.00 0.00 0.00 01/01/2000
01/02/2000 12345 XYZ-987 0000054321 001 0030 100.00 175.00 10.00 10.00 01/01/2000
01/03/2000 12347 ABC-123 0000012345 001 0020 25.00 75.00 5.00 1.00 01/02/2000
01/03/2000 12348 ABC-123 0000012345 001 0020 75.00 120.00 25.00 5.00 01/02/2000
01/03/2000 12349 XYZ-987 0000054321 001 0050 50.00 110.00 0.00 0.00 01/02/2000
01/04/2000 12350 ABC-123 0000012345 001 0030 25.00 40.00 0.00 0.00 01/03/2000
ISSUE_COST
unit_iss_cost ord_nbr sub_ord_nbr
125.00 0000012345 001
650.00 0000054321 001
ORD
ord_nbr sub_ord_nbr major_seq_nbr qty_complete
0000012345 001 0010 10
0000012345 001 0020 10
0000012345 001 0030 0
0000054321 001 0030 20
0000054321 001 0050 19If insert statements are needed for the sample tables, let me know and I'll go re-figure out how to write them. (I only have read-only access to the database I'm querying, so creating tables and inserting values aren't things I ever do).
Thanks in advance!For diagnosing where the time of your query is being spent, we don't need create table and insert statements. If we execute your query with only a handful of rows, the query will be very fast. What we do need to know, is the plan the optimizer takes to compute your result set, and the cardinalities of each step.
Please read When your query takes too long ... carefully and post the full explain plan and tkprof output.
Regards,
Rob. -
Need help getting I-tunes to run on XP
I have tried most all the tricks listed and still I-tunes will not run on relatively new windows XP, Dell machine (also newly purchased I-pod), - I have disabled virus protection, I have loaded most recent versions of i-tunes, I have cleared temp files and reloaded. I tried loading Q-time player as a stand alone. I deleted old folders of I-tunes and Q-time and reloaded.
I-tunes down-loads without any error message. the I-pod connects to USB and charges - and shows up as an "E" drive. But clicking on i-tunes icon, or loading audio disk or connecting I-pod all fail to visably launch i-tunes (nothing is seen in task manager after attempting to launch I-tunes - but on shut down of the computer I get the message that I-tunes is not responding and must be shut down manually) (also for grins I tried launching newly loaded Q-time -> I get message saying its loading, but this message never clears). Already 10 hours spent on thisHello,
Unfortunantly, I'm not quite good in JavaScript to give you a good response. But I can you give you an advise, that can help you:
1. Add a simle system.out.println("Init called!"); message in public void init() method of the servlet RefreshInfo.
2. Try to access servlet by simple browser request "http://localhost:8080/yourApp/RefreshInfo".
2. If the message "Init called!" appears in the Tomcat console, your servlet code is correct and the serlet is described properly in web.xml . In this case, the possible problem is in the JavaScript code.
Good day,
http://www.myjavaserver.com/~voronetskyy/ -
Need help with Performance Tuning
Following query takes 8 secs. Any help will be appreciated
SELECT SUM(FuturesMarketVal) FuturesMarketVal
FROM (SELECT CASE WHEN null IS NULL THEN FuturesMarketVal
ELSE DECODE(FUTURES_NAME, null, FuturesMarketVal, 0)
END FuturesMarketVal
FROM (SELECT SUM( (a.FUTURES_ALLOC * (NVL(b.Futures_EOD_Price,0)/100 - NVL(c.Futures_EOD_Price,0)/100) * a.CONTRACT_SIZE) / DECODE(a.CONTRACT_SIZE,100000,1,1000000,4,3000000,12,1) ) FuturesMarketVal,
a.FUTURES_NAME
FROM cms_futures_trans a,
cms_futures_price b,
cms_futures_price c
Where c.history_date (+) = TO_DATE(fas_pas_pkg.get_weekday(to_date('12/30/2005') - 1),'mm/dd/yyyy')
and a.FUTURES_NAME = b.FUTURES_NAME (+)
AND a.trade_date < TO_DATE('12/30/2005','mm/dd/yyyy')
AND b.history_date (+) = TO_DATE('12/30/2005','mm/dd/yyyy')
AND a.FUTURES_NAME = c.FUTURES_NAME (+)
GROUP BY a.FUTURES_NAME
/Eric:
But there are only 5 records in cms_futures_price and 10 in cms_futures_trans :-)
OP:
I'm not usre what you are trying to fo here, but a couple of comments.
Since NULL IS NULL will always be true, you don;t really need the CASE statement. as it stands, your query will always return FuturesMarketVal. If the results are correct, then you can do without the DECODE as well.
Why are you calling fas_pas_pkg.get_weekday with a constant value? Can you not just use whatever it returns as a constant instead of calling the function?
Are you sure you need all those outer joins? They almost guarantee full scans of the outer joined tables.
Perhaps if you post some representative data from the two tables and an explanation of what you are trying to accomplish someone may have a better idea.
John -
Hard drive crash... need help with i Tunes....
Hello all,
Here is the problem. A couple of weeks ago my girlfriend's hard drive crashed. I was able to pull her hard drive out and slave it to mine, in order to save her docs/pics/I-tunes. I got everything off and burned it to a couple of DVDs.
My question is how do I get those music files (the ones I recovered) back on to her new computer?
Thanks,
Jason
Windows XP
PS. Her i-Pod does have all of her music files... If that matters...There's a program called PodUtil (http://www.kennettnet.co.uk/software/podutil.php)-the trial works, you don't have to buy it. And you can get all of the songs/videos from your girlfriend's iPod and move it to a designated folder, once you do that, simply add folder to iTunes. Hope I helped...post questions if you have any.
-
Need help on performing database queries with a general query
Dear experts,
I have two issues
1)
I have developed a software which connects to Oracle database
performing and executing DDL/DML statements.
I am using a Jdbc thin oracle driver.
When i perform a wrong syntax query or say a query using invalid column.I get exception accordingly.However,I want to know if there is any way by which i can know the exact position where i am making error
just as an asterik(*) comes in sql plus in case of invalid column or so.
2)
Whenever i minimize software window (made of swing components)
and again maximize it.It takes almost 12 secs to be visible otherwise it remains white.Is swing that much slow ???(1) No.
(2) It's possible to make Swing programs that slow. (I know, I have done it.) But usually the slowness is in application code (your code) and not in Swing itself.
Maybe you are looking for
-
Cannot open Reader program, no error messages (Windows XP, SP3)
Hello all! I am hoping someone can provide a solution to my frustration.... Earlier this summer I was having some computer trouble. The computer was under warranty - HP came out and changed the memory and system board. I have not been having any issu
-
I just installed Arch from Opensuse 11 following this guide http://wiki.archlinux.org/index.php/Ins … ting_Linux . I installed Gnome 2.24 desktop through OpenSuse also. However, when I log into Arch, the internet (wired) is not working. I have insta
-
Problem in configuring SSO using SAML for applications hosted on diff m/c
Hi Techies, I am stuck in a weird problem for past month or so without any resolution. Not much help by googling. So I hope i get the answer from the mouth of the horses - I am trying to use SSO using the sample application appA and appB as stated in
-
How can i transfer oracle table's
Hi there can anybody help?, i wana use my oracle table's ( that i created in system) and wana to use those table in another system (it doest have oracle software ). is ther any possible way to use entire oracle table's in a system without installing
-
Disk Utility Reports Permissions Repaired, but Don't Verify
I run permissions repair (as I've been having kernel panics), and there is a bunch of stuff that gets reported as fixed. However, as soon as the repair is complete, if I run Verify Disk Permissions, it reports back the same errors. See the log below: