Help for Rewrite/tune the quey
Hi,
Could you please help to rewrite or tune the below query.
database
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bitQuery
SELECT *
FROM
(SELECT q.*,
ROWNUM AS rowindex,
COUNT(*) OVER() AS record_count
FROM
(SELECT get_cand_session_number(ccr.split_session_year,ccr.split_session_month,ccr.candidate) AS candidate_session_number,
ca.candidate,
ca.lastname,
ca.firstname,
(SELECT csl.status_type
FROM ibis.cw_status_lookup csl
WHERE csl.status_id = ccp.status_id
) AS status,
ccp.candidate_portfolio_id
FROM ibis.candidate_component_reg ccr
INNER JOIN
(SELECT self_taught,
YEAR,
MONTH,
main_school,
candidate,
subject,
subject_option,
lvl,
language,
withdrawn,
programme
FROM ibis.candidate_subject_registration
) csr
ON csr.year = :v_year
AND csr.month =:v_month
AND csr.main_school =ccr.main_school
AND csr.candidate =ccr.candidate
AND csr.subject =ccr.subject
AND csr.subject_option=ccr.subject_option
AND csr.lvl = ccr.lvl
AND csr.language =ccr.language
AND csr.withdrawn ='N'
INNER JOIN
(SELECT YEAR,
MONTH,
candidate,
programme,
exam_seq_num
FROM ibis.candidate_session_detail
) csd
ON csd.year = :v_year
AND csd.month = :v_month
AND csd.candidate = csr.candidate
AND csd.programme = ccr.programme
AND csd.exam_seq_num = NVL(NULL,csd.exam_seq_num)
INNER JOIN
(SELECT candidate,lastname,firstname FROM ibis.candidate
) ca
ON ca.candidate=csd.candidate
INNER JOIN
(SELECT status_id,
candidate_portfolio_id,
YEAR,
MONTH,
paper_code,
candidate
FROM ibis.cw_candidate_portfolio
) ccp
ON ccp.year = :v_year
AND ccp.month = :v_month
AND ccp.paper_code = ccr.paper_code
AND ccp.candidate = ccr.candidate
WHERE ccr.split_session_year = :v_year
AND ccr.split_session_month = :v_month
AND ccr.component = :v_component
AND ccr.withdrawn ='N'
AND ccr.assessment_school =NVL(:v_school_code,ccr.assessment_school)
AND ccr.subject = NVL(:v_subject,ccr.subject)
AND ccr.subject_option = NVL(:v_subject_option,ccr.subject_option)
AND ccr.lvl = NVL(:v_lvl,ccr.lvl)
AND ccr.language = NVL(:v_language,ccr.language)
AND ((csr.self_taught ='N'
AND ccr.sampled ='Y'
AND ccr.deleted_from_sample ='N'
AND EXISTS
(SELECT 1
FROM ibis.subject_component sc
WHERE sc.year = ccr.split_session_year
AND sc.month = ccr.split_session_month
AND ccr.paper_code =sc.paper_code
AND sc.subject = ccr.subject
AND sc.subject_option =ccr.subject_option
AND sc.lvl = ccr.lvl
AND sc.language =ccr.language
AND sc.component =ccr.component
AND sc.assessment_method_id = 11
AND sc.assessment_type = 'INTERNAL'
AND NOT EXISTS
(SELECT 1
FROM ibis.cw_portfolio_template cpt
WHERE ccr.split_session_year = cpt.year
AND ccr.split_session_month = cpt.month
AND ccr.subject = cpt.subject
AND ccr.subject_option = cpt.subject_option
AND ccr.component = cpt.component
AND cpt.combined = 'Y'
OR (csr.self_taught='Y'
AND EXISTS
(SELECT 1
FROM ibis.subject_component sc
WHERE sc.year = ccr.split_session_year
AND sc.month = ccr.split_session_month
AND ccr.paper_code =sc.paper_code
AND sc.subject = ccr.subject
AND sc.subject_option =ccr.subject_option
AND sc.lvl = ccr.lvl
AND sc.language =ccr.language
AND sc.component =ccr.component
AND sc.assessment_method_id = 11
AND sc.assessment_type = 'INTERNAL'
AND NOT EXISTS
(SELECT 1
FROM ibis.cw_portfolio_template cpt
WHERE ccr.split_session_year = cpt.year
AND ccr.split_session_month = cpt.month
AND ccr.subject = cpt.subject
AND ccr.subject_option = cpt.subject_option
AND ccr.component = cpt.component
AND cpt.combined = 'Y'
OR (EXISTS
(SELECT 1
FROM ibis.cw_portfolio_template cpt
WHERE ccr.split_session_year = cpt.year
AND ccr.split_session_month = cpt.month
AND ccr.subject = cpt.subject
AND ccr.subject_option = cpt.subject_option
AND ccr.component = cpt.component
AND cpt.combined = 'Y'
AND EXISTS
(SELECT 1
FROM ibis.subject_component sc
WHERE sc.year = ccr.split_session_year
AND sc.month = ccr.split_session_month
AND ccr.paper_code =sc.paper_code
AND sc.subject = ccr.subject
AND sc.subject_option =ccr.subject_option
AND sc.lvl = ccr.lvl
AND sc.language =ccr.language
AND sc.component =ccr.component
AND sc.assessment_method_id = 11
UNION
SELECT get_cand_session_number(ssm.year,ssm.month,ccr.candidate) AS candidate_session_number,
ca.candidate,
ca.lastname,
ca.firstname,
(SELECT csl.status_type
FROM ibis.cw_status_lookup csl
WHERE csl.status_id = ccp.status_id
) AS status,
ccp.candidate_portfolio_id
FROM ibis.school_sample_mark_additional ssm,
ibis.candidate_component_reg ccr,
ibis.candidate ca,
ibis.candidate_session_detail csd,
ibis.cw_candidate_portfolio ccp
WHERE ssm.year = :v_year
AND ssm.month = :v_month
AND ssm.candidate IS NOT NULL
AND ssm.year = ccr.split_session_year
AND ssm.month =ccr.split_session_month
AND ccr.assessment_school =ssm.school_code
AND ssm.candidate =ccr.candidate
AND ssm.paper_code = ccr.paper_code
AND ccr.component = :v_component
AND ccr.split_session_year = csd.year
AND ccr.split_session_month = csd.month
AND ccr.candidate =csd.candidate
AND ccr.programme = csd.programme
AND csd.candidate =ca.candidate
AND ccr.split_session_year = ccp.year
AND ccr.split_session_month = ccp.month
AND ccr.paper_code =ccp.paper_code
AND ccr.candidate = ccp.candidate
AND ssm.school_code = NVL(:v_school_code,ssm.school_code)
AND ccr.subject = NVL(:v_subject,ccr.subject)
AND ccr.subject_option = NVL(:v_subject_option,ccr.subject_option)
AND ccr.lvl = NVL(:v_lvl,ccr.lvl)
AND ccr.language = NVL(:v_language,ccr.language)
AND csd.exam_seq_num = NVL(:v_candidate,csd.exam_seq_num)
)q
) sq
WHERE ROWINDEX >=:v_startrow
AND ROWINDEX <= (:v_startrow + (:v_maxrows - 1) );explain plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 4 | 8708 | 363 (1)| 00:00:06 |
|* 1 | FILTER | | | | | |
|* 2 | VIEW | | 4 | 8708 | 363 (1)| 00:00:06 |
| 3 | WINDOW BUFFER | | 4 | 8604 | 363 (1)| 00:00:06 |
| 4 | COUNT | | | | | |
| 5 | VIEW | | 4 | 8604 | 363 (1)| 00:00:06 |
| 6 | SORT UNIQUE | | 4 | 1016 | 363 (14)| 00:00:06 |
| 7 | UNION-ALL | | | | | |
| 8 | CONCATENATION | | | | | |
|* 9 | FILTER | | | | | |
|* 10 | FILTER | | | | | |
| 11 | TABLE ACCESS BY INDEX ROWID | CW_CANDIDATE_PORTFOLIO | 1 | 44 | 3 (0)| 00:00:01 |
| 12 | NESTED LOOPS | | 1 | 270 | 299 (1)| 00:00:05 |
| 13 | NESTED LOOPS | | 1 | 226 | 296 (1)| 00:00:05 |
| 14 | NESTED LOOPS | | 1 | 200 | 294 (1)| 00:00:05 |
| 15 | NESTED LOOPS | | 35 | 3080 | 190 (1)| 00:00:03 |
| 16 | TABLE ACCESS BY INDEX ROWID| CANDIDATE_SESSION_DETAIL | 35 | 980 | 92 (2)| 00:00:02 |
|* 17 | INDEX RANGE SCAN | SESSION_SCHL_CAND | 35 | | 77 (2)| 00:00:02 |
|* 18 | TABLE ACCESS BY INDEX ROWID| CANDIDATE_SUBJECT_REGISTRATION | 1 | 60 | 3 (0)| 00:00:01 |
|* 19 | INDEX RANGE SCAN | Y_M_CAND_SUBJ_LVL_OPTION | 1 | | 2 (0)| 00:00:01 |
|* 20 | TABLE ACCESS BY INDEX ROWID | CANDIDATE_COMPONENT_REG | 1 | 112 | 3 (0)| 00:00:01 |
|* 21 | INDEX RANGE SCAN | SPLIT_SESSION_CANDIDATE | 1 | | 2 (0)| 00:00:01 |
| 22 | TABLE ACCESS BY INDEX ROWID | CANDIDATE | 1 | 26 | 2 (0)| 00:00:01 |
|* 23 | INDEX UNIQUE SCAN | CANDIDATE_PK | 1 | | 1 (0)| 00:00:01 |
|* 24 | INDEX RANGE SCAN | CANDIDATE_PORTFOLIO_INDEX1 | 1 | | 2 (0)| 00:00:01 |
|* 25 | TABLE ACCESS BY INDEX ROWID | CW_PORTFOLIO_TEMPLATE | 1 | 46 | 4 (0)| 00:00:01 |
|* 26 | INDEX RANGE SCAN | YEAR_MON_PORTFOLIO_TEMPLATE | 1 | | 3 (0)| 00:00:01 |
|* 27 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 96 | 4 (0)| 00:00:01 |
|* 28 | INDEX RANGE SCAN | SUBJECT_COMPONENT_PK | 1 | | 3 (0)| 00:00:01 |
|* 29 | TABLE ACCESS BY INDEX ROWID | CW_PORTFOLIO_TEMPLATE | 1 | 46 | 4 (0)| 00:00:01 |
|* 30 | INDEX RANGE SCAN | YEAR_MON_PORTFOLIO_TEMPLATE | 1 | | 3 (0)| 00:00:01 |
|* 31 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 96 | 4 (0)| 00:00:01 |
|* 32 | INDEX RANGE SCAN | SUBJECT_COMPONENT_PK | 1 | | 3 (0)| 00:00:01 |
|* 33 | TABLE ACCESS BY INDEX ROWID | CW_PORTFOLIO_TEMPLATE | 1 | 46 | 4 (0)| 00:00:01 |
|* 34 | INDEX RANGE SCAN | YEAR_MON_PORTFOLIO_TEMPLATE | 1 | | 3 (0)| 00:00:01 |
|* 35 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 87 | 4 (0)| 00:00:01 |
|* 36 | INDEX RANGE SCAN | SUBJECT_COMPONENT_PK | 1 | | 3 (0)| 00:00:01 |
|* 37 | FILTER | | | | | |
|* 38 | FILTER | | | | | |
| 39 | NESTED LOOPS | | 1 | 270 | 16 (0)| 00:00:01 |
| 40 | NESTED LOOPS | | 1 | 244 | 14 (0)| 00:00:01 |
| 41 | NESTED LOOPS | | 1 | 216 | 12 (0)| 00:00:01 |
| 42 | NESTED LOOPS | | 1 | 156 | 9 (0)| 00:00:01 |
|* 43 | TABLE ACCESS BY INDEX ROWID | CANDIDATE_COMPONENT_REG | 1 | 112 | 6 (0)| 00:00:01 |
|* 44 | INDEX RANGE SCAN | ASSESSMENT_SPLIT_SESSION | 1 | | 5 (0)| 00:00:01 |
| 45 | TABLE ACCESS BY INDEX ROWID | CW_CANDIDATE_PORTFOLIO | 1 | 44 | 3 (0)| 00:00:01 |
|* 46 | INDEX RANGE SCAN | CANDIDATE_PORTFOLIO_INDEX1 | 1 | | 2 (0)| 00:00:01 |
|* 47 | TABLE ACCESS BY INDEX ROWID | CANDIDATE_SUBJECT_REGISTRATION | 1 | 60 | 3 (0)| 00:00:01 |
|* 48 | INDEX RANGE SCAN | CAND_REG_SCHOOL | 1 | | 2 (0)| 00:00:01 |
|* 49 | TABLE ACCESS BY INDEX ROWID | CANDIDATE_SESSION_DETAIL | 1 | 28 | 2 (0)| 00:00:01 |
|* 50 | INDEX UNIQUE SCAN | CANDIDATE_DETAIL_PK | 1 | | 1 (0)| 00:00:01 |
| 51 | TABLE ACCESS BY INDEX ROWID | CANDIDATE | 1 | 26 | 2 (0)| 00:00:01 |
|* 52 | INDEX UNIQUE SCAN | CANDIDATE_PK | 1 | | 1 (0)| 00:00:01 |
|* 53 | TABLE ACCESS BY INDEX ROWID | CW_PORTFOLIO_TEMPLATE | 1 | 46 | 4 (0)| 00:00:01 |
|* 54 | INDEX RANGE SCAN | YEAR_MON_PORTFOLIO_TEMPLATE | 1 | | 3 (0)| 00:00:01 |
|* 55 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 96 | 4 (0)| 00:00:01 |
|* 56 | INDEX RANGE SCAN | SUBJECT_COMPONENT_PK | 1 | | 3 (0)| 00:00:01 |
|* 57 | TABLE ACCESS BY INDEX ROWID | CW_PORTFOLIO_TEMPLATE | 1 | 46 | 4 (0)| 00:00:01 |
|* 58 | INDEX RANGE SCAN | YEAR_MON_PORTFOLIO_TEMPLATE | 1 | | 3 (0)| 00:00:01 |
|* 59 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 96 | 4 (0)| 00:00:01 |
|* 60 | INDEX RANGE SCAN | SUBJECT_COMPONENT_PK | 1 | | 3 (0)| 00:00:01 |
|* 61 | TABLE ACCESS BY INDEX ROWID | CW_PORTFOLIO_TEMPLATE | 1 | 46 | 4 (0)| 00:00:01 |
|* 62 | INDEX RANGE SCAN | YEAR_MON_PORTFOLIO_TEMPLATE | 1 | | 3 (0)| 00:00:01 |
|* 63 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 87 | 4 (0)| 00:00:01 |
|* 64 | INDEX RANGE SCAN | SUBJECT_COMPONENT_PK | 1 | | 3 (0)| 00:00:01 |
| 65 | CONCATENATION | | | | | |
|* 66 | FILTER | | | | | |
| 67 | TABLE ACCESS BY INDEX ROWID | CW_CANDIDATE_PORTFOLIO | 1 | 44 | 3 (0)| 00:00:01 |
| 68 | NESTED LOOPS | | 1 | 238 | 23 (0)| 00:00:01 |
| 69 | NESTED LOOPS | | 1 | 194 | 20 (0)| 00:00:01 |
| 70 | NESTED LOOPS | | 1 | 168 | 18 (0)| 00:00:01 |Edited by: user575115 on
Hi
i have seen your query and i am nt changing the whole query but i'll recommend some of the changes it may helps in the performance tuning...
1) write all the filter conditions in the FROM clause in correspondence to the tables for ex :
One way : select * from tab a, tab1 b where a.c = b.c and a.d in ('xx','lll')
Tuned way : select * from (select c from tab where d in ('xx','lll')) a, tab b where a.c = b.c (it provides lesser rows for joining)
2) Donot write Inline query in the select statement.You can try it.
for ex:
One way : select a.c, (select d from tab1 where tab1.d = a.e) from tab a
tuned way : select a.c, tab1.d from tab a, tab1 where tab1.d = a.e
3) Check the gathering of stats in 10G
4) Avoid using ANSI standered for JOINS for ex : Instead of select * from a inner join a on ... use select * from a, b where joining cond.(I am not confirmed)
5) If possible here use the WITH clause becuase you have use UNION and you have use some common tables which are executing twice in the current.
6) Use some HINTS like FIRST_ROWS
If somewhere i am wrong please correct me.
Edited by: user9292111 on 22-Mar-2012 01:52
Edited by: user9292111 on 22-Mar-2012 01:53
Similar Messages
-
HOW to Restrict the input Help for 0MATERIAL in the BPS Layout
Hi,
I have requirement to Restrict the input Help for 0MATERIAL in the BPS Layout.
For Example if the Planning Package is Restricted to SALES ORGANISATION ( 3000 ) then the system shuold check the 0MAT_SALES where SALES ORGANISATION IS "3000" )AND PASS THE Material Numbers to the 0material list.
I have Copied the standard Funtcion group "UPF_VARIABLE_USER_EXIT" to Z fucttion and have attached to Z Variabe as User Exit .
this Variable is Attached to 0material in the Planning Pakage. So tha now the 0MATERIAL is restricted to the variable which is having the User Exit.
But how to acces the Values of Planning Package for which the Layout is bein Executed from this Z User Exit ???
I Know how to restrict the input help, but my only problem is that how to get the values of Planning package through this User Exit.
Please suggest if it is possible.
Regards,
Nilesh LabdeHi Nilesh,
As I understand from your question,you know how to restrict but the issue is to know the value in the package with which you need to restrict.
There are two tables which can help you finding the value used in package for sales organisation:
1. UPC_PACKAGE
2. UPC_OPTIOS
How to use ?
From UPC Package you will get one GUID, Hit the second table UPC_OPTIOS with this GUID.
In field "FIELDNAME" enter the name of the characteristic whose value is req (sales organisation in your case)
Hope this helps you
Mann -
Help for rewrite or tune this quer
Hi,
can u some help to rewrite or tune this quer.
SELECT 20100201 PERIOD_KEY,CONSUMER_KEY,DOW_KEY PREFDOW,nvl(FIN_SCOR_DOW,-1),'MONTH' GRANULAR FROM
SELECT CONSUMER_KEY,DOW_KEY,FIN_SCOR_DOW,
ROW_NUMBER() OVER ( PARTITION BY CONSUMER_KEY ORDER BY FIN_SCOR_DOW DESC,DOW_KEY ) RNO
FROM
SELECT CONSUMER_KEY,DOW_KEY,SUM(SCORE_SERVICE_WEIGHT) FIN_SCOR_DOW FROM
SELECT DOW_KEY,CONSUMER_KEY,SERVICE_KEY,DUR,TRAN,VOLU,TOT_DUR,CUM_DUR,TOT_TRAN,CUM_TRAN,TOT_VOL,CUM_VOL,SCORE_DUR,SCORE_TRAN,SCORE_VOL,
1*NVL(SCORE_DUR,0)+1*NVL(SCORE_TRAN,0)+1*NVL(SCORE_VOL,0) TOT_SCOR ,
CASE
WHEN SERVICE_KEY= 0 THEN
1*SCORE_DUR
WHEN SERVICE_KEY IN ('1','3') THEN
1*SCORE_TRAN
WHEN SERVICE_KEY = 2 THEN
1*SCORE_VOL
END SCORE_SERVICE_WEIGHT FROM
select DOW_KEY,consumer_key,service_key,sumDUR dur,SUMTRAN tran,sumVOL volu,
tot_dur,cum_dur,tot_tran,cum_tran,tot_vol,cum_vol,
case
when tot_dur > 0 then
cum_dur*100/tot_dur
end score_dur,
case
when tot_tran > 0 then
cum_tran*100/tot_tran
end score_tran,
case
when tot_vol > 0 then
cum_vol*100/tot_vol
end score_vol
from
SELECT CONSUMER_KEY,SERVICE_KEY,DOW_KEY,SUMDUR,SUMTRAN,SUMVOL,SUM(SUMDUR) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ) TOT_DUR,
SUM(SUMDUR) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMDUR,DOW_KEY) CUM_DUR,
--SUM(SUMDUR) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMDUR,DOW_KEY,RNO) CUM_DUR,
SUM(SUMTRAN) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ) TOT_TRAN,
SUM(SUMTRAN) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMTRAN,DOW_KEY) CUM_TRAN,
--SUM(SUMDUR) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMDUR,DOW_KEY,RNO) CUM_DUR,
SUM(SUMVOL) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ) TOT_VOL,
SUM(SUMVOL) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMVOL,DOW_KEY) CUM_VOL
--SUM(SUMDUR) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMDUR,DOW_KEY,RNO) CUM_DUR,
FROM
SELECT CONSUMER_KEY,SERVICE_KEY, to_number(to_char(to_date(DATE_KEY,'YYYYMMDD'),'D')) DOW_KEY,
sum(SUM_OF_DURATION) sumdur,SUM(NO_OF_TRANSACTIONS) sumtran,sum(SUM_OF_VOLUME) sumvol
--ROW_NUMBER () OVER (ORDER BY CONSUMER_KEY) RNO
FROM SERVICE_FACTS_BY_DAY
WHERE DATE_KEY BETWEEN 20100201 AND 20100228
group by CONSUMER_KEY,SERVICE_KEY,to_number(to_char(to_date(DATE_KEY,'YYYYMMDD'),'D'))
ORDER BY CONSUMER_KEY,SERVICE_KEY,to_number(to_char(to_date(DATE_KEY,'YYYYMMDD'),'D'))
GROUP BY CONSUMER_KEY,DOW_KEY
WHERE RNO=1;explain plan
Plan hash value: 3130556327
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 571K| 28M| | 128K (1)| 00:29:54 | | |
|* 1 | VIEW | | 571K| 28M| | 128K (1)| 00:29:54 | | |
|* 2 | WINDOW SORT PUSHED RANK | | 571K| 59M| 217M| 128K (1)| 00:29:54 | | |
| 3 | HASH GROUP BY | | 571K| 59M| 217M| 128K (1)| 00:29:54 | | |
| 4 | VIEW | | 1713K| 179M| | 93314 (1)| 00:21:47 | | |
| 5 | WINDOW SORT | | 1713K| 127M| 157M| 93314 (1)| 00:21:47 | | |
| 6 | WINDOW SORT | | 1713K| 127M| 157M| 93314 (1)| 00:21:47 | | |
| 7 | WINDOW SORT | | 1713K| 127M| 157M| 93314 (1)| 00:21:47 | | |
| 8 | VIEW | | 1713K| 127M| | 34903 (2)| 00:08:09 | | |
| 9 | SORT GROUP BY | | 1713K| 40M| 340M| 34903 (2)| 00:08:09 | | |
| 10 | PARTITION RANGE ITERATOR| | 8090K| 192M| | 13172 (2)| 00:03:05 | 1 | 25 |
|* 11 | TABLE ACCESS FULL | SERVICE_FACTS_BY_DAY | 8090K| 192M| | 13172 (2)| 00:03:05 | 1 | 25 |
Predicate Information (identified by operation id):
1 - filter("RNO"=1)
2 - filter(ROW_NUMBER() OVER ( PARTITION BY "CONSUMER_KEY" ORDER BY SUM(CASE "SERVICE_KEY" WHEN 0 THEN 1*CASE WHEN
("TOT_DUR">0) THEN ("CUM_DUR"*100/"TOT_DUR") END WHEN 1 THEN 1*CASE WHEN ("TOT_TRAN">0) THEN
("CUM_TRAN"*100/"TOT_TRAN") END WHEN 3 THEN 1*CASE WHEN ("TOT_TRAN">0) THEN ("CUM_TRAN"*100/"TOT_TRAN") END WHEN 2
THEN 1*CASE WHEN ("TOT_VOL">0) THEN ("CUM_VOL"*100/"TOT_VOL") END END ) DESC ,"DOW_KEY")<=1)
11 - filter("DATE_KEY"<=20100228 AND "DATE_KEY">=20100201)You are posting your request to the Enterprise Manager Grid Control forum.
So I assume that you are using OEM Grig Control.
You could then start using the SQL Tuning Advisor to provide you with an alternative query, execution plan etc.
If you are not using OEM Grid Control, I suggest that you post your request to a Database forum.
Regards
Rob -
Hi,
can u some help to rewrite or tune this quer.
SELECT 20100201 PERIOD_KEY,CONSUMER_KEY,DOW_KEY PREFDOW,nvl(FIN_SCOR_DOW,-1),'MONTH' GRANULAR FROM
SELECT CONSUMER_KEY,DOW_KEY,FIN_SCOR_DOW,
ROW_NUMBER() OVER ( PARTITION BY CONSUMER_KEY ORDER BY FIN_SCOR_DOW DESC,DOW_KEY ) RNO
FROM
SELECT CONSUMER_KEY,DOW_KEY,SUM(SCORE_SERVICE_WEIGHT) FIN_SCOR_DOW FROM
SELECT DOW_KEY,CONSUMER_KEY,SERVICE_KEY,DUR,TRAN,VOLU,TOT_DUR,***_DUR,TOT_TRAN,***_TRAN,TOT_VOL,***_VOL,SCORE_DUR,SCORE_TRAN,SCORE_VOL,
1*NVL(SCORE_DUR,0)+1*NVL(SCORE_TRAN,0)+1*NVL(SCORE_VOL,0) TOT_SCOR ,
CASE
WHEN SERVICE_KEY= 0 THEN
1*SCORE_DUR
WHEN SERVICE_KEY IN ('1','3') THEN
1*SCORE_TRAN
WHEN SERVICE_KEY = 2 THEN
1*SCORE_VOL
END SCORE_SERVICE_WEIGHT FROM
select DOW_KEY,consumer_key,service_key,sumDUR dur,SUMTRAN tran,sumVOL volu,
tot_dur,***_dur,tot_tran,***_tran,tot_vol,***_vol,
case
when tot_dur > 0 then
***_dur*100/tot_dur
end score_dur,
case
when tot_tran > 0 then
***_tran*100/tot_tran
end score_tran,
case
when tot_vol > 0 then
***_vol*100/tot_vol
end score_vol
from
SELECT CONSUMER_KEY,SERVICE_KEY,DOW_KEY,SUMDUR,SUMTRAN,SUMVOL,SUM(SUMDUR) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ) TOT_DUR,
SUM(SUMDUR) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMDUR,DOW_KEY) ***_DUR,
--SUM(SUMDUR) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMDUR,DOW_KEY,RNO) ***_DUR,
SUM(SUMTRAN) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ) TOT_TRAN,
SUM(SUMTRAN) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMTRAN,DOW_KEY) ***_TRAN,
--SUM(SUMDUR) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMDUR,DOW_KEY,RNO) ***_DUR,
SUM(SUMVOL) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ) TOT_VOL,
SUM(SUMVOL) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMVOL,DOW_KEY) ***_VOL
--SUM(SUMDUR) OVER (PARTITION BY CONSUMER_KEY,SERVICE_KEY ORDER BY SUMDUR,DOW_KEY,RNO) ***_DUR,
FROM
SELECT CONSUMER_KEY,SERVICE_KEY, to_number(to_char(to_date(DATE_KEY,'YYYYMMDD'),'D')) DOW_KEY,
sum(SUM_OF_DURATION) sumdur,SUM(NO_OF_TRANSACTIONS) sumtran,sum(SUM_OF_VOLUME) sumvol
--ROW_NUMBER () OVER (ORDER BY CONSUMER_KEY) RNO
FROM SERVICE_FACTS_BY_DAY
WHERE DATE_KEY BETWEEN 20100201 AND 20100228
group by CONSUMER_KEY,SERVICE_KEY,to_number(to_char(to_date(DATE_KEY,'YYYYMMDD'),'D'))
ORDER BY CONSUMER_KEY,SERVICE_KEY,to_number(to_char(to_date(DATE_KEY,'YYYYMMDD'),'D'))
GROUP BY CONSUMER_KEY,DOW_KEY
WHERE RNO=1;explain plan
Plan hash value: 3130556327
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 571K| 28M| | 128K (1)| 00:29:54 | | |
|* 1 | VIEW | | 571K| 28M| | 128K (1)| 00:29:54 | | |
|* 2 | WINDOW SORT PUSHED RANK | | 571K| 59M| 217M| 128K (1)| 00:29:54 | | |
| 3 | HASH GROUP BY | | 571K| 59M| 217M| 128K (1)| 00:29:54 | | |
| 4 | VIEW | | 1713K| 179M| | 93314 (1)| 00:21:47 | | |
| 5 | WINDOW SORT | | 1713K| 127M| 157M| 93314 (1)| 00:21:47 | | |
| 6 | WINDOW SORT | | 1713K| 127M| 157M| 93314 (1)| 00:21:47 | | |
| 7 | WINDOW SORT | | 1713K| 127M| 157M| 93314 (1)| 00:21:47 | | |
| 8 | VIEW | | 1713K| 127M| | 34903 (2)| 00:08:09 | | |
| 9 | SORT GROUP BY | | 1713K| 40M| 340M| 34903 (2)| 00:08:09 | | |
| 10 | PARTITION RANGE ITERATOR| | 8090K| 192M| | 13172 (2)| 00:03:05 | 1 | 25 |
|* 11 | TABLE ACCESS FULL | SERVICE_FACTS_BY_DAY | 8090K| 192M| | 13172 (2)| 00:03:05 | 1 | 25 |
Predicate Information (identified by operation id):
1 - filter("RNO"=1)
2 - filter(ROW_NUMBER() OVER ( PARTITION BY "CONSUMER_KEY" ORDER BY SUM(CASE "SERVICE_KEY" WHEN 0 THEN 1*CASE WHEN
("TOT_DUR">0) THEN ("***_DUR"*100/"TOT_DUR") END WHEN 1 THEN 1*CASE WHEN ("TOT_TRAN">0) THEN
("***_TRAN"*100/"TOT_TRAN") END WHEN 3 THEN 1*CASE WHEN ("TOT_TRAN">0) THEN ("***_TRAN"*100/"TOT_TRAN") END WHEN 2
THEN 1*CASE WHEN ("TOT_VOL">0) THEN ("***_VOL"*100/"TOT_VOL") END END ) DESC ,"DOW_KEY")<=1)
11 - filter("DATE_KEY"<=20100228 AND "DATE_KEY">=20100201)The two inner most SQL views could probably be combined into one:
SELECT CONSUMER_KEY
,SERVICE_KEY
,TO_NUMBER(TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D')) DOW_KEY
,SUM(SUM_OF_DURATION)
OVER (PARTITION BY CONSUMER_KEY, SERVICE_KEY, TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D') ) TOT_DUR
,SUM(SUM_OF_DURATION)
OVER (PARTITION BY CONSUMER_KEY, SERVICE_KEY, TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D')
ORDER BY TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D') ) STAR_DUR
,SUM(NO_OF_TRANSACTIONS)
OVER (PARTITION BY CONSUMER_KEY, SERVICE_KEY, TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D') ) TOT_TRAN
,SUM(NO_OF_TRANSACTIONS)
OVER (PARTITION BY CONSUMER_KEY, SERVICE_KEY, TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D')
ORDER BY TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D') ) STAR_TRAN
,SUM(SUM_OF_VOLUME)
OVER (PARTITION BY CONSUMER_KEY, SERVICE_KEY, TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D') ) TOT_VOL
,SUM(SUM_OF_VOLUME)
OVER (PARTITION BY CONSUMER_KEY, SERVICE_KEY, TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D')
ORDER BY TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D') ) STAR_VOL
FROM SERVICE_FACTS_BY_DAY
WHERE DATE_KEY BETWEEN 20100201 AND 20100228
GROUP BY CONSUMER_KEY
,SERVICE_KEY
,TO_NUMBER(TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D'))
ORDER BY CONSUMER_KEY
,SERVICE_KEY
,TO_NUMBER(TO_CHAR(TO_DATE(DATE_KEY,'YYYYMMDD'),'D'))Also, read up on all the linear regression functions:
REGR_ (Linear Regression)in
http://www.morganslibrary.org/reference/analytic_functions.html
this view ;
select DOW_KEY
,CONSUMER_KEY
,SERVICE_KEY
,SUMDUR DUR
,SUMTRAN TRAN
,SUMVOL VOLU
,TOT_DUR
,STAR_DUR
,TOT_TRAN
,STAR_TRAN
,TOT_VOL
,STAR_VOL
,CASE
WHEN TOT_DUR > 0 THEN
STAR_DUR * 100 / TOT_DUR
END SCORE_DUR
,CASE
WHEN TOT_TRAN > 0 THEN
STAR_TRAN * 100 / TOT_TRAN
END SCORE_TRAN
,CASE
WHEN TOT_VOL > 0 THEN
STAR_VOL * 100 / TOT_VOL
END SCORE_VOLcould probably be simplified if you make use of analytical functions, but you'll have to be prepared to play around and test and re-test dozens of times, before you get what you want. -
Help needed to tune the Query:Statistics added
Can someone DBA please help me to tune this query:
SELECT DISTINCT K.ATTRIBUTE_VALUE AGENCY_ID,B.PROFILE_NM ,NVL(G.OFFICE_DESC,'--') OFFICE_DESC,f.OFFICE_ID,B.PROFILE_ID,'%' ROLE,'%' LAYOUT,
CASE
WHEN 'flagB' = '%' THEN
NVL(J.ISS_GRP_DESC,'BILLING')
WHEN 'flagO' = '%' THEN
NVL(J.ISS_GRP_DESC,'ORDERING')
WHEN 'flag' = '%' THEN
NVL(J.ISS_GRP_DESC,'BILLING/ORDERING')
ELSE
NVL(J.ISS_GRP_DESC,' ')
END ISS_GRP_DESC,
DECODE(NVL(H.USERID,' ') ,' ','--','<a sbcuid_in=' || H.USERID || ' target=NEW >'||H.FIRSTNAME || ' ' || H.LASTNAME || '( ' || H.USERID || ' )</a>' ) USER_NAME
FROM
PROFILE_PORTAL B ,
TBL_BDA_AGENCY_RESP_REP C ,
TBL_BDA_AGENCY_OFFICE F,
TBL_BDA_OFFICE G,
USERS_PORTAL H,
TBL_BDA_USR_ISS_GRP I ,
TBL_BDA_ISS_GROUP J,
ATTRIBUTE_VALUES_PORTAL K,
PROFILE_TYPE_PORTAL L
WHERE
B.PROFILE_ID = F.AGENCY_ID (+)
AND B.PROFILE_ID = C.AGENCY_ID (+)
AND G.OFFICE_ID (+)= F.OFFICE_ID
AND H.USERID (+)= C.RESP_USR_ID
AND C.ISS_GRP_ID = I.ISS_GRP_ID (+)
AND I.ISS_GRP_ID = J.ISS_GRP_ID(+)
AND 'PROFILE.'||B.PROFILE_ID = K.ENTITY_ID(+)
AND K.ATTRIBUTE_VALUE IS NOT NULL
AND L.PROFILE_TYPE_ID = B.PROFILE_TYPE_ID
AND L.APPLICATION_CD='BDA'
AND NOT EXISTS (SELECT agency_id
FROM TBL_BDA_AGENCY_RESP_REP t
WHERE t.ISS_GRP_ID IN ('%')
AND t.AGENCY_ID = C.AGENCY_ID)
AND K.ATTRIBUTE_VALUE LIKE '%'
AND UPPER(B.PROFILE_NM) LIKE UPPER('%')
AND (to_char(NVL(B.PROFILE_ID,0)) LIKE '%' OR NVL(B.PROFILE_ID,0) IN ('a'))
AND NVL(G.OFFICE_ID,0) IN ('%')
AND (to_char(NVL(C.RESP_USR_ID,'0')) LIKE '%' OR NVL(C.RESP_USR_ID,'0') IN ('k'))
ORDER BY PROFILE_NM
The number of rows in these tables are as follows:
PROFILE_PORTAL -- 2392
TBL_BDA_AGENCY_RESP_REP 3508
TBL_BDA_AGENCY_OFFICE 2151
TBL_BDA_OFFICE 3
USERS_PORTAL 270500
TBL_BDA_USR_ISS_GRP 234
TBL_BDA_ISS_GROUP 2
ATTRIBUTE_VALUES_PORTAL 2790
PROFILE_TYPE_PORTAL 3
The Explain pal nhas given this o/p to me:
SQL> select * from table(dbms_xplan.display) dual;
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
| 0 | SELECT STATEMENT | | 807 | 102K| | 2533 |
| 1 | SORT UNIQUE | | 807 | 102K| 232K| 82 |
|* 2 | FILTER | | | | | |
|* 3 | HASH JOIN OUTER | | 807 | 102K| | 52 |
|* 4 | HASH JOIN OUTER | | 807 | 95226 | | 40 |
|* 5 | TABLE ACCESS BY INDEX ROWID | ATTRIBUTE_VALUES | 1 | 23 | | 2 |
| 6 | NESTED LOOPS | | 7 | 805 | | 37 |
| 7 | NESTED LOOPS OUTER | | 6 | 552 | | 25 |
|* 8 | FILTER | | | | | |
| 9 | NESTED LOOPS OUTER | | | | | |
|* 10 | FILTER | | | | | |
| 11 | NESTED LOOPS OUTER | | | | | |
| 12 | NESTED LOOPS OUTER | | 3 | 141 | | 10 |
|* 13 | HASH JOIN | | 3 | 120 | | 7 |
|* 14 | TABLE ACCESS FULL | PROFILE | 6 | 198 | | 4 |
|* 15 | TABLE ACCESS FULL | PROFILE_TYPE | 1 | 7 | | 2 |
|* 16 | INDEX RANGE SCAN | SYS_C0019777 | 1 | 7 | | 1 |
| 17 | TABLE ACCESS BY INDEX ROWID| TBL_BDA_OFFICE | 1 | 10 | | 1 |
|* 18 | INDEX UNIQUE SCAN | SYS_C0019800 | 1 | | | |
| 19 | TABLE ACCESS BY INDEX ROWID | TBL_BDA_AGENCY_RESP_REP | 2 | 26 | | 2 |
|* 20 | INDEX RANGE SCAN | IDX_AGECYRESP_AGNCYID | 2 | | | 1 |
| 21 | TABLE ACCESS BY INDEX ROWID | USER_ | 1 | 22 | | 1 |
|* 22 | INDEX UNIQUE SCAN | USER_PK | 1 | | | |
|* 23 | INDEX RANGE SCAN | IDX_ATTVAL_ENTATTID | 1 | | | 1 |
| 24 | TABLE ACCESS FULL | TBL_BDA_USR_ISS_GRP | 234 | 702 | | 2 |
| 25 | TABLE ACCESS FULL | TBL_BDA_ISS_GROUP | 2 | 24 | | 2 |
|* 26 | TABLE ACCESS BY INDEX ROWID | TBL_BDA_AGENCY_RESP_REP | 1 | 7 | | 3 |
|* 27 | INDEX RANGE SCAN | IDX_AGECYRESP_AGNCYID | 2 | | | 1 |
Predicate Information (identified by operation id):
2 - filter( NOT EXISTS (SELECT /*+ */ 0 FROM "TBL_BDA_AGENCY_RESP_REP" "T" WHERE "T"."AGENCY_ID"=:B1
AND "T"."ISS_GRP_ID"=TO_NUMBER('%')))
3 - access("I"."ISS_GRP_ID"="J"."ISS_GRP_ID"(+))
4 - access("SYS_ALIAS_1"."ISS_GRP_ID"="I"."ISS_GRP_ID"(+))
5 - filter("K"."ATTRIBUTE_VALUE" IS NOT NULL AND "K"."ATTRIBUTE_VALUE" LIKE '%')
8 - filter(NVL("SYS_ALIAS_1"."RESP_USR_ID",'0') LIKE '%' OR NVL("SYS_ALIAS_1"."RESP_USR_ID",'0')='k')
10 - filter(NVL("G"."OFFICE_ID",0)=TO_NUMBER('%'))
13 - access("L"."PROFILE_TYPE_ID"="B"."PROFILE_TYPE_ID")
14 - filter(UPPER("B"."PROFILE_NM") LIKE '%' AND (TO_CHAR(NVL("B"."PROFILE_ID",0)) LIKE '%' OR
NVL("B"."PROFILE_ID",0)=TO_NUMBER('a')))
15 - filter("L"."APPLICATION_CD"='BDA')
16 - access("B"."PROFILE_ID"="F"."AGENCY_ID"(+))
18 - access("G"."OFFICE_ID"(+)="F"."OFFICE_ID")
20 - access("B"."PROFILE_ID"="SYS_ALIAS_1"."AGENCY_ID"(+))
22 - access("H"."USERID"(+)="SYS_ALIAS_1"."RESP_USR_ID")
23 - access("K"."ENTITY_ID"='PROFILE.'||TO_CHAR("B"."PROFILE_ID"))
26 - filter("T"."ISS_GRP_ID"=TO_NUMBER('%'))
27 - access("T"."AGENCY_ID"=:B1)
Note: cpu costing is off
57 rows selected.
Elapsed: 00:00:01.08
Please help me.
Aashish S.Hello Eric,
Here is the code:
SELECT DISTINCT
K.ATTRIBUTE_VALUE AGENCY_ID,
B.PROFILE_NM ,
NVL(G.OFFICE_DESC,'--') OFFICE_DESC,
f.OFFICE_ID,
B.PROFILE_ID,
'%' ROLE,
'%' LAYOUT,
case
WHEN 'flagB' = '%' THEN
NVL(J.ISS_GRP_DESC,'BILLING')
WHEN 'flagO' = '%' THEN
NVL(J.ISS_GRP_DESC,'ORDERING')
WHEN 'flag' = '%' THEN
NVL(J.ISS_GRP_DESC,'BILLING/ORDERING')
else
NVL(J.ISS_GRP_DESC,' ')
END ISS_GRP_DESC,
DECODE(NVL(H.USERID,' ') ,' ','--','<a sbcuid_in=' || H.USERID || ' target=NEW >'||H.FIRSTNAME || ' ' || H.LASTNAME ||
'( ' || H.USERID || ' )</a>' ) USER_NAME
from
PROFILE_PORTAL B ,
TBL_BDA_AGENCY_RESP_REP C ,
TBL_BDA_AGENCY_OFFICE F,
TBL_BDA_OFFICE G,
USERS_PORTAL H,
TBL_BDA_USR_ISS_GRP I ,
TBL_BDA_ISS_GROUP J,
ATTRIBUTE_VALUES_PORTAL K,
PROFILE_TYPE_PORTAL L
WHERE
B.PROFILE_ID = F.AGENCY_ID (+)
AND B.PROFILE_ID = C.AGENCY_ID (+)
AND G.OFFICE_ID (+)= F.OFFICE_ID
AND H.USERID (+)= C.RESP_USR_ID
AND C.ISS_GRP_ID = I.ISS_GRP_ID (+)
AND I.ISS_GRP_ID = J.ISS_GRP_ID(+)
AND 'PROFILE.'||B.PROFILE_ID = K.ENTITY_ID(+)
AND K.ATTRIBUTE_VALUE IS NOT NULL
AND L.PROFILE_TYPE_ID = B.PROFILE_TYPE_ID
AND L.APPLICATION_CD='BDA'
AND NOT EXISTS
(SELECT agency_id
FROM TBL_BDA_AGENCY_RESP_REP t
WHERE t.ISS_GRP_ID IN (1)
AND t.AGENCY_ID = C.AGENCY_ID)
AND K.ATTRIBUTE_VALUE LIKE '%'
AND UPPER(B.PROFILE_NM) LIKE UPPER('%')
AND (to_char(NVL(B.PROFILE_ID,0))
LIKE '%'
OR NVL(B.PROFILE_ID,0) IN (1))
AND NVL(G.OFFICE_ID,0) IN (1)
AND (to_char(NVL(C.RESP_USR_ID,'0'))
LIKE '%'
OR NVL(C.RESP_USR_ID,'0') IN ('%'))
ORDER BY PROFILE_NM
This is the Query and the query takes some mins. to run in prod environment.
From the Query plan ,I am not able to get any idea for optimization.
Now,Can you tell me which steps I need to follow to run it faster and which all modifications should be made?
Thanks.
Aashish S. -
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 -
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. -
Hi all:
I'm new to the world of i-tunes. I just bought a $14 i-tune album, and it won't work
on my MP3 player because, as it turns out, the songs are in MPEG4 format?
Can I solve this somehow? Or can I get a refund from i-tunes to get my money back?
Thanks for your help!Click here for information.
(61900) -
Help required regarding tunning the query mentioned
HI all ,
Query mentioned below takes around 1 hr to complete . It's being used by the autoconfig kindly me in tunning it ..
QUery :
UPDATE WF_ITEM_ATTRIBUTE_VALUES WIAV SET WIAV.TEXT_VALUE = REPLACE(WIAV.TEXT_VALUE,:B1,:B2)
WHERE (WIAV.ITEM_TYPE, WIAV.NAME) = (SELECT WIA.ITEM_TYPE, WIA.NAME
FROM WF_ITEM_ATTRIBUTES WIA WHERE WIA.TYPE = 'URL'
AND WIA.ITEM_TYPE = WIAV.ITEM_TYPE
AND WIA.NAME = WIAV.NAME)
AND WIAV.TEXT_VALUE IS NOT NULL
AND INSTR(WIAV.TEXT_VALUE
, :B1) > 0
Plan :*
<pre>
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | UPDATE STATEMENT | | 453 | 14496 | 284K|
| 1 | UPDATE | WF_ITEM_ATTRIBUTE_VALUES | | | |
|* 2 | FILTER | | | | |
|* 3 | TABLE ACCESS FULL | WF_ITEM_ATTRIBUTE_VALUES | 453 | 14496 | 282K|
|* 4 | TABLE ACCESS BY INDEX ROWID| WF_ITEM_ATTRIBUTES | 1 | 33 | 2 |
|* 5 | INDEX UNIQUE SCAN | WF_ITEM_ATTRIBUTES_PK | 1 | | 1 |
Predicate Information (identified by operation id):
2 - filter(("SYS_ALIAS_2"."ITEM_TYPE","SYS_ALIAS_2"."NAME")= (SELECT /*+ */
"WIA"."ITEM_TYPE","WIA"."NAME" FROM "APPLSYS"."WF_ITEM_ATTRIBUTES" "WIA" WHERE
"WIA"."NAME"=:B1 AND "WIA"."ITEM_TYPE"=:B2 AND "WIA"."TYPE"='URL'))
3 - filter("SYS_ALIAS_2"."TEXT_VALUE" IS NOT NULL AND
INSTR("SYS_ALIAS_2"."TEXT_VALUE",:Z)>0)
4 - filter("WIA"."TYPE"='URL')
5 - access("WIA"."ITEM_TYPE"=:B1 AND "WIA"."NAME"=:B2)
</pre>
Index :*
<pre>
INDEX_NAME COLUMN_NAME
APPLSYS WF_ITEM_ATTRIBUTE_VALUES_PK 1 ITEM_TYPE
2 ITEM_KEY
3 NAME
</pre>
regds
Rahul
Edited by: RahulG on Jan 2, 2009 10:47 PM
Edited by: RahulG on Jan 2, 2009 10:48 PMRahulG wrote:
HI all ,
Query mentioned below takes around 1 hr to complete . It's being used by the autoconfig kindly me in tunning it ..
A few notes:
1. Your query is using bind variables. If you're already on 9i or later (probably 9iR2 according to plan output), this statement will be subject to bind variable peeking and therefore the output of EXPLAIN PLAN is only of limited use, since the actual execution plan might be different and/or might be based on different cardinality estimates based on the actual bind values peeked at hard parse time. You can use the V$SQL_PLAN view to get the actual execution plan(s) if the statement is still cached in the shared pool, from 10g on DBMS_XPLAN.DISPLAY_CURSOR is available for that purpose.
2. The execution plan posted suggests that only 453 rows will correspond to the filter criteria (but, as mentioned in 1. is based on an unknown bind variable value when using EXPLAIN PLAN), and probably therefore the optimizer didn't unnest the subquery but runs this as recursive FILTER query potentially for each row passing the filter criteria on the driving table WF_ITEM_ATTRIBUTE_VALUES. Depending on the actual number of rows this might be inefficient, and unnesting the subquery and turning it into a join might be more appropriate. This might accomplished e.g. by providing more representative statistics to the optimizer (are the statistics up-to-date?).
Although you can't change the SQL you could try this manually by using the UNNEST hint to see if it makes any difference in the execution plan (and run time):
WHERE (WIAV.ITEM_TYPE, WIAV.NAME) = (SELECT /*+ UNNEST */ WIA.ITEM_TYPE, WIA.NAME
...3. The composite index WF_ITEM_ATTRIBUTE_VALUES_PK can only be used on the first column ITEM_TYPE for effective index access, the NAME column would have to be used as filter on all index leaf blocks that would be found using a range scan on ITEM_TYPE. This might be quite inefficient, and/or might lead to a lot of rows/blocks that need to be visited in the table using this index access path.
4. You could try to trace the execution by enabling extended SQL trace, e.g. using the (undocumented) DBMS_SUPPORT package in 9i. Running the "tkprof" utility on the generated trace file tells you the actual row source cardinalities (which can then be compared to the estimates of the optimizer) and - if the "waits" have been enabled - what your statement has waited for most.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Help for install of the download oracle 8.05
hi friends:
I download the oracle 8.0.5 , i used redhat5.1,
but i dont know how to install . so sorry ,
and i dont know how to Set the kernel parameters correponding to(
SHMMAX, SHMMNI, SHMSEG, SHMMNS)
can you give me some advices , i really thanks very much.
thanks very much.
please give me the details of the install thanks very much.
please give me your hlep to my e_mail :[email protected]
too. thanks very much.
your frined:lzh
nulldear Joslyn Gordon:
THANK VERY MUCH.
I follow your advice 1.2.3.4.but
5. I have some difficult.
I cd the orainst.but cant find the install command?
why .
the oracle is i download frome internet 805ship.tar.
I really need your help.
your friend:lzh
Joslyn Gordon (guest) wrote:
: There are docs on the CDROM in the unixdocs directory.
: Basically you need to:
: 1. create a group named dba.
: 2. create a user named oracle, make user a member of dba
: 3. log in as oracle user
: 4. set ORACLE_HOME using: ORACLE_HOME = <oracle user
: homedirectory>; export ORACLE_SID
: 5. set ORACLE_SID using: ORACLE_SID = <Database Name> e.g.
: ORACLE_SID = MYDB; export ORACLE_SID
: 6. run the installer in the CDROM orainst directory:
: install -d <oracle_home>.
: where oracle_home is the home directory for oracle user.
: I installed on 5.1 without setting the kernel params. I find
that
: in a lot of cases you can install without setting params. The
: database won't start up if these aren't correctly set.
: I had no problems starting the database.
: lzh (guest) wrote:
: : hi friends:
: : I download the oracle 8.0.5 , i used redhat5.1,
: : but i dont know how to install . so sorry ,
: : and i dont know how to Set the kernel parameters
correponding
: to(
: : SHMMAX, SHMMNI, SHMSEG, SHMMNS)
: : can you give me some advices , i really thanks very much.
: : thanks very much.
: : please give me the details of the install thanks very much.
: : please give me your hlep to my e_mail
:[email protected]
: : too. thanks very much.
: : your frined:lzh
null -
Help for processing of the FM 'BAPI_INSPOPER_GETDETAIL'.
Hi,
Can anyone please help me with the processing of the FM 'BAPI_INSPOPER_GETDETAIL'.
There seems to be no documentation on this FM on the net or on SDN.
I basically need to use this FM to fetch the values of three fields Target Value (SOLLWERT) , Lower Tolerance Limit (TOLERANZUN) and Upper Tolerance Limit (TOLERANZOB).
Currently I am not able to this but there seems to be some way out of it. Please help.
Thanks.Hi,
Please pass the below data for BAPI 'BAPI_INSPOPER_GETDETAIL'.
CALL FUNCTION 'BAPI_INSPOPER_GETDETAIL'
EXPORTING
insplot = '010000000001'
inspoper = '0010'
read_insppoints = 'X'
read_char_requirements = 'X'
read_char_results = 'X'
read_sample_results = 'X'
read_single_results = 'X'
read_chars_with_classes = 'X'
read_chars_without_recording = 'X'
res_org = ' '
char_filter_no = '1 '
char_filter_tcode = 'QE11'
max_insppoints = 100
insppoint_from = 0
TABLES
CHAR_REQUIREMENTS = it_charreq
From table IT_CHARREQ you can get lower tolerance limit(IT_CHARREQ - LW_TOL_LMT),Upper tolerance limit(IT_CHARREQ - UP_TOL_LMT),Target value (IT_CHARREQ-TARGET_VAL).
Hope this may helpful.
Regards,
Sravanthi. -
How do I get my 4s to sync over the air?
Sync over the air with what, exactly?
-
Creating search help for AFNAM, and display the hit list with values only
Hi guys,
I have created a search help for AFNAM, but the hit list displays all even if it is blank.
I want to display in the hit list the AFNAM with values and do not diplay the blank values...
Is it possible? How am i going to do it?
Thanks!
MarkHi Mark,
After selecting data use this statement.
DELETE it_table WHERE AFNAM is initial.
Regards,
Suneel G -
Search help for a field using a selection method which has a text table.
Hello all,
I am trying to create a search help for one of the fields in a structure say RFCDEST. Now for this i am giving the selection method as the DB table where all the RFCDEST are maintained. However there is a text table which is also comes up for this selection method and the description of the filed RFCDEST is in that text table and the description is not stored in the main table which i specified as the selection method.
My query is that on F4 now all the rfc destinations are being shown however the description i am not able to show them because there is no field in the table specified in the selectionmethod which hold s the description but instead it is there in the text table, how can i fetch the description from there and display in the search help.
Warm Regards,
Naveen Mlook at search help FC_RFCDEST. that problem has already been solved with this search help.
-
Best practice for application help for a custom screen?
Hi,
The system is Netweaver 7.0 SP 15 with e-recruiting .
We have some custom SAP GUI transactions and have written Word documents with screen prints and explanations. I would like to make the procedure document accessible from the custom transaction or at least provide custom help text that includes a link to the full documents.
Can anyone help me out with options and best practices for providing customized application help for custom SAP GUI transactions?
Thanks,
MargaretHello Margaret,
sorry I though you might be still in a design or proof of concept phase where the decision for the technology is still adjustable.
If the implementation is already done things change of course. The standard in-system documentation is surely not fitting your needs as including screenshots won't work well.
I would solve the task the following way:
I'd make a web or pdf document out of the word document and put it on a web ressource - as you run e-recruiting you have probably the possibility for that.
I would then just put a button into the transaction an open a web container to show the document.
I am not sure if this solution really qualifies as "best practise" but SAP does the same if you call the Help for application in the help menue. This is implemented in function module SAPGUIHC_OPEN_HELP_CENTER. I'd just copy it, throw out what I do not need and hard code the url to call.
Perhaps someone could offer a better solution but I think this works a t least without exxagerated costs.
Kind Regards
Roman
Maybe you are looking for
-
Century gothic displays in adobe reader 8 and not in 9
Hi I have created a pdf using adobe livecycle and i have set the address font in my header to Century Gothic. When i view the doc in Adobe reader 8, it shows it exactly the way i want. When i view it in adobe 9, it has changed to arial. Why is this h
-
Work book created in 7.0 not working in 3.x
Hi all, I have created a workbook in Bex 7.0 and it is working fine. But users have 3.5 version of Bex in their system. I know that in case of query I can save it in 3.x but in case of workbooki is it possible that a workbook, which is created in 7.0
-
Hi All can anyone tell me how EDI settings are done for Purchase orders and intercompany billing docs. Transaction codes would be of much help step by step.i think i know there are four Tcodes. WEL1 for logical address , WE20 for partner profiles and
-
[solved] sharing internet from windows computer with arch laptop
Title is descriptive I think. Stuck on windows on my desktop because I did a thing and don't feel like fixing it yet I used ICS but the laptop couldn't access the internet and I read someplace that it only works between a windows client and host, and
-
Unanswered questions...
Hi buddies, Here is some of the questions which i couldn't find a clear answer for them. I believe they are extremely needed in all projects. Hope to find a resolution in next version. 1- Modal Frame. 2- JBO Exception customization. 3- Find Panel dat