Performance Problem in Select query
Hi,
I have performance Problem in following Select Query :
SELECT VBELN POSNR LFIMG VRKME VGBEL VGPOS
FROM LIPS INTO CORRESPONDING FIELDS OF TABLE GT_LIPS
FOR ALL ENTRIES IN GT_EKPO1
WHERE VGBEL = GT_EKPO1-EBELN
AND VGPOS = GT_EKPO1-EBELP.
as per trace i have analysed that it is fetch the complete table scan from the LIPS table and table contants almost 3 lakh records.
Kindly Suggest what we can do to optimize this query.
Regards,
Harsh
types: begin of line,
vbeln type lips-vbeln
posnr type lips-posnr
lfimg type lips-lfimg
vrkme type lips-vrkme
vgbel type lips- vgbel
vgpos type lips-vgpos
end of line.
data: itab type standard table of line,
wa type line.
IF GT_EKPO1[] IS NOT INITIAL.
SELECT VBELN POSNR LFIMG VRKME VGBEL VGPOS
FROM LIPS INTO TABLE ITAB
FOR ALL ENTRIES IN GT_EKPO1
WHERE VGBEL = GT_EKPO1-EBELN
AND VGPOS = GT_EKPO1-EBELP.
ENDIF.
Similar Messages
-
Performance problem at Select Query
Hello all,
I have a performance question. Which code can i use instead of this code
" select * from t001a into table it_tp_auth where bukrs in kd_bukrs ".
thus the program runs faster ?
Regards
HeidiHi all,
that was my estimation. But I go into wrong direction.
I must TC : FB1lN optimize.
My Problem:
if I select my interval for company code largely, the program (RFITEMAP) is very slow. What I can make in this report, so that preformance becomes better.
Example: ( selection criterion )
company code : 1 to 200 -
> very slow
company code: 1 ---> normal
My estimation:
if I write a report, with same selection screen. In this report
can I call with (Submit) FBL1N and transfer all entered values to FBL1N ?
report:
report dummy.
tables: lfa.
select-options: bukrs for lfa-bukrs.
start-of-selection.
loop at bukrs into wa_bukrs.
SUBMIT FBL1N with p_param1 =wa_bukrs.
endloop.
is this realizable ?
best regards
Heidi
Edited by: Heidi Heinzberger on Sep 16, 2008 10:13 PM -
Performance problem in select query again
Hi Experts,
I have another performance issue with this.
Select matnr werks from marc
Into table i_marc
For all entries in i_mara
Where matnr eq i_mara-matnr.
Loop at I_mara.
Read table i_marc with key matnr = I_mara-matnr.
Endloop.
When I showed this code to my boss he suggested me to do some performance tuning.But i do not have any idea what to do.I am already using for all entries.
Please suggest.
NeetiRead statement fetches the record from the internal table using implicit key or explicit key. When no key or index is specified for the search criteria the key in the WA of the internal table is used implicitly for searching. Here the key or index is explicitly specified which is used for searching the records from internal table. This is faster than an implicit search.
When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ. Therefore, SORT the table and use READ TABLE WITH KEY BINARY SEARCH.
Select matnr from mara
Into table i_mara
Where matnr in s_matnr.
Select matnr werks from marc
Into table i_marc
For all entries in i_mara
Where matnr eq i_mara-matnr.
Sort I_marc by matnr.
Loop at I_mara.
Read table i_marc with key
matnr = I_mara-matnr
binary search.
Endloop. -
Performance problem with selecting records from BSEG and KONV
Hi,
I am having performance problem while selecting records from BSEG and KONV table. As these two tables have large amount of data , they are taking lot of time . Can anyone help me in improving the performance . Thanks in advance .
Regards,
PrashantHi,
Some steps to improve performance
SOME STEPS USED TO IMPROVE UR PERFORMANCE:
1. Avoid using SELECT...ENDSELECT... construct and use SELECT ... INTO TABLE.
2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
3. Design your Query to Use as much index fields as possible from left to right in your WHERE statement
4. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
5. Avoid using nested SELECT statement SELECT within LOOPs.
6. Avoid using INTO CORRESPONDING FIELDS OF TABLE. Instead use INTO TABLE.
7. Avoid using SELECT * and Select only the required fields from the table.
8. Avoid nested loops when working with large internal tables.
9. Use assign instead of into in LOOPs for table types with large work areas
10. When in doubt call transaction SE30 and use the examples and check your code
11. Whenever using READ TABLE use BINARY SEARCH addition to speed up the search. Be sure to sort the internal table before binary search. This is a general thumb rule but typically if you are sure that the data in internal table is less than 200 entries you need not do SORT and use BINARY SEARCH since this is an overhead in performance.
12. Use "CHECK" instead of IF/ENDIF whenever possible.
13. Use "CASE" instead of IF/ENDIF whenever possible.
14. Use "MOVE" with individual variable/field moves instead of "MOVE-
CORRESPONDING" creates more coding but is more effcient. -
Performance issue with select query and for all entries.
hi,
i have a report to be performance tuned.
the database table has around 20 million entries and 25 fields.
so, the report fetches the distinct values of two fields using one select query.
so, the first select query fetches around 150 entries from the table for 2 fields.
then it applies some logic and eliminates some entries and makes entries around 80-90...
and then it again applies the select query on the same table using for all entries applied on the internal table with 80-90 entries...
in short,
it accesses the same database table twice.
so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
is around 80-90 entries too much for using "for all entries"?
the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
i really cant find the way out...
please help.chinmay kulkarni wrote:Chinmay,
Even though you tried to ask the question with detailed explanation, unfortunately it is still not clear.
It is perfectly fine to access the same database twice. If that is working for you, I don't think there is any need to change the logic. As Rob mentioned, 80 or 8000 records is not a problem in "for all entries" clause.
>
> so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
>
It is not clear what you tried to do here. Did you try to bring all 20 million records into an internal table? That will certainly cause the program to short dump with memory shortage.
> the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
>
That is fine. Actually, it is better (performance wise) to do much of the work in ABAP than writing a complex WHERE clause that might bog down the database. -
Needed help to improve the performance of a select query?
Hi,
I have been preparing a report which involves data to be fetched from 4 to 5 different tables and calculation has to performed on some columns also,
i planned to write a single cursor to populate 1 temp table.i have used INLINE VIEW,EXISTS more frequently in the select query..please go through the query and suggest me a better way to restructure the query.
cursor c_acc_pickup_incr(p_branch_code varchar2, p_applDate date, p_st_dt date, p_ed_dt date) is
select sca.branch_code "BRANCH",
sca.cust_ac_no "ACCOUNT",
to_char(p_applDate, 'YYYYMM') "YEARMONTH",
sca.ccy "CURRENCY",
sca.account_class "PRODUCT",
sca.cust_no "CUSTOMER",
sca.ac_desc "DESCRIPTION",
null "LOW_BAL",
null "HIGH_BAL",
null "AVG_CR_BAL",
null "AVG_DR_BAL",
null "CR_DAYS",
null "DR_DAYS",
--null "CR_TURNOVER",
--null "DR_TURNOVER",
null "DR_OD_DAYS",
(select sum(gf.limit_amount * (scal.linkage_percentage / 100)) +
(case when (p_applDate >= sca.tod_limit_start_date and
p_applDate <= nvl(sca.tod_limit_end_date, p_applDate)) then
sca.tod_limit else 0 end) dd
from getm_facility gf, sttm_cust_account_linkages scal
where gf.line_code || gf.line_serial = scal.linked_ref_no
and cust_ac_no = sca.cust_ac_no) "OD_LIMIT",
--sc.credit_rating "CR_GRADE",
null "AVG_NET_BAL",
null "UNAUTH_OD_AMT",
sca.acy_blocked_amount "AMT_BLOCKED",
(select sum(amt)
from ictb_entries_history ieh
where ieh.acc = sca.cust_ac_no
and ieh.brn = sca.branch_code
and ieh.drcr = 'D'
and ieh.liqn = 'Y'
and ieh.entry_passed = 'Y'
and ieh.ent_dt between p_st_dt and p_ed_dt
and exists (
select * from ictm_pr_int ipi, ictm_rule_frm irf
where ipi.product_code = ieh.prod
and ipi.rule = irf.rule_id
and irf.book_flag = 'B')) "DR_INTEREST",
(select sum(amt)
from ictb_entries_history ieh
where ieh.acc = sca.cust_ac_no
and ieh.brn = sca.branch_code
and ieh.drcr = 'C'
and ieh.liqn = 'Y'
and ieh.entry_passed = 'Y'
and ieh.ent_dt between p_st_dt and p_ed_dt
and exists (
select * from ictm_pr_int ipi, ictm_rule_frm irf
where ipi.product_code = ieh.prod
and ipi.rule = irf.rule_id
and irf.book_flag = 'B')) "CR_INTEREST",
(select sum(amt) from ictb_entries_history ieh
where ieh.brn = sca.branch_code
and ieh.acc = sca.cust_ac_no
and ieh.ent_dt between p_st_dt and p_ed_dt
and exists (
select product_code
from ictm_product_definition ipd
where ipd.product_code = ieh.prod
and ipd.product_type = 'C')) "FEE_INCOME",
sca.record_stat "ACC_STATUS",
case when (trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
and not exists (select 1
from ictm_tdpayin_details itd
where itd.multimode_payopt = 'Y'
and itd.brn = sca.branch_code
and itd.acc = sca.cust_ac_no
and itd.multimode_offset_brn is not null
and itd.multimode_tdoffset_acc is not null))
then 1 else 0 end "NEW_ACC_FOR_THE_MONTH",
case when (trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
and trunc(sc.cif_creation_date,'MM') = trunc(p_applDate,'MM')
and not exists (select 1
from ictm_tdpayin_details itd
where itd.multimode_payopt = 'Y'
and itd.brn = sca.branch_code
and itd.acc = sca.cust_ac_no
and itd.multimode_offset_brn is not null
and itd.multimode_tdoffset_acc is not null))
then 1 else 0 end "NEW_ACC_FOR_NEW_CUST",
(select 1 from dual
where exists (select 1 from ictm_td_closure_renew itcr
where itcr.brn = sca.branch_code
and itcr.acc = sca.cust_ac_no
and itcr.renewal_date = sysdate)
or exists (select 1 from ictm_tdpayin_details itd
where itd.multimode_payopt = 'Y'
and itd.brn = sca.branch_code
and itd.acc = sca.cust_ac_no
and itd.multimode_offset_brn is not null
and itd.multimode_tdoffset_acc is not null)) "RENEWED_OR_ROLLOVER",
(select maturity_date from ictm_acc ia
where ia.brn = sca.branch_code
and ia.acc = sca.cust_ac_no) "MATURITY_DATE",
sca.ac_stat_no_dr "DR_DISALLOWED",
sca.ac_stat_no_cr "CR_DISALLOWED",
sca.ac_stat_block "BLOCKED_ACC", Not Reqd
sca.ac_stat_dormant "DORMANT_ACC",
sca.ac_stat_stop_pay "STOP_PAY_ACC", --New
sca.ac_stat_frozen "FROZEN_ACC",
sca.ac_open_date "ACC_OPENING_DT",
sca.address1 "ADD_LINE_1",
sca.address2 "ADD_LINE_2",
sca.address3 "ADD_LINE_3",
sca.address4 "ADD_LINE_4",
sca.joint_ac_indicator "JOINT_ACC",
sca.acy_avl_bal "CR_BAL",
0 "DR_BAL",
0 "CR_BAL_LCY", t
0 "DR_BAL_LCY",
null "YTD_CR_MOVEMENT",
null "YTD_DR_MOVEMENT",
null "YTD_CR_MOVEMENT_LCY",
null "YTD_DR_MOVEMENT_LCY",
null "MTD_CR_MOVEMENT",
null "MTD_DR_MOVEMENT",
null "MTD_CR_MOVEMENT_LCY",
null "MTD_DR_MOVEMENT_LCY",
'N' "BRANCH_TRFR", --New
sca.provision_amount "PROVISION_AMT",
sca.account_type "ACCOUNT_TYPE",
nvl(sca.tod_limit, 0) "TOD_LIMIT",
nvl(sca.sublimit, 0) "SUB_LIMIT",
nvl(sca.tod_limit_start_date, global.min_date) "TOD_START_DATE",
nvl(sca.tod_limit_end_date, global.max_date) "TOD_END_DATE"
from sttm_cust_account sca, sttm_customer sc
where sca.branch_code = p_branch_code
and sca.cust_no = sc.customer_no
and ( exists (select 1 from actb_daily_log adl
where adl.ac_no = sca.cust_ac_no
and adl.ac_branch = sca.branch_code
and adl.trn_dt = p_applDate
and adl.auth_stat = 'A')
or exists (select 1 from catm_amount_blocks cab
where cab.account = sca.cust_ac_no
and cab.branch = sca.branch_code
and cab.effective_date = p_applDate
and cab.auth_stat = 'A')
or exists (select 1 from ictm_td_closure_renew itcr
where itcr.acc = sca.cust_ac_no
and itcr.brn = sca.branch_code
and itcr.renewal_date = p_applDate)
or exists (select 1 from sttm_ac_stat_change sasc
where sasc.cust_ac_no = sca.cust_ac_no
and sasc.branch_code = sca.branch_code
and sasc.status_change_date = p_applDate
and sasc.auth_stat = 'A')
or exists (select 1 from cstb_acc_brn_trfr_log cabtl
where cabtl.branch_code = sca.branch_code
and cabtl.cust_ac_no = sca.cust_ac_no
and cabtl.process_status = 'S'
and cabtl.process_date = p_applDate)
or exists (select 1 from sttbs_provision_history sph
where sph.branch_code = sca.branch_code
and sph.cust_ac_no = sca.cust_ac_no
and sph.esn_date = p_applDate)
or exists (select 1 from sttms_cust_account_dormancy scad
where scad.branch_code = sca.branch_code
and scad.cust_ac_no = sca.cust_ac_no
and scad.dormancy_start_dt = p_applDate)
or sca.maker_dt_stamp = p_applDate
or sca.status_since = p_applDate
l_tb_acc_det ty_tb_acc_det_int;
l_brnrec cvpks_utils.rec_brnlcy;
l_acbr_lcy sttms_branch.branch_lcy%type;
l_lcy_amount actbs_daily_log.lcy_amount%type;
l_xrate number;
l_dt_rec sttm_dates%rowtype;
l_acc_rec sttm_cust_account%rowtype;
l_acc_stat_row ty_r_acc_stat;
Edited by: user13710379 on Jan 7, 2012 12:18 AMI see it more like shown below (possibly with no inline selects
Try to get rid of the remaining inline selects ( left as an exercise ;) )
and rewrite traditional joins as ansi joins as problems might arise using mixed syntax as I have to leave so I don't have time to complete the query
select sca.branch_code "BRANCH",
sca.cust_ac_no "ACCOUNT",
to_char(p_applDate, 'YYYYMM') "YEARMONTH",
sca.ccy "CURRENCY",
sca.account_class "PRODUCT",
sca.cust_no "CUSTOMER",
sca.ac_desc "DESCRIPTION",
null "LOW_BAL",
null "HIGH_BAL",
null "AVG_CR_BAL",
null "AVG_DR_BAL",
null "CR_DAYS",
null "DR_DAYS",
-- null "CR_TURNOVER",
-- null "DR_TURNOVER",
null "DR_OD_DAYS",
w.dd "OD_LIMIT",
-- sc.credit_rating "CR_GRADE",
null "AVG_NET_BAL",
null "UNAUTH_OD_AMT",
sca.acy_blocked_amount "AMT_BLOCKED",
x.dr_int "DR_INTEREST",
x.cr_int "CR_INTEREST",
y.fee_amt "FEE_INCOME",
sca.record_stat "ACC_STATUS",
case when trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
and not exists(select 1
from ictm_tdpayin_details itd
where itd.multimode_payopt = 'Y'
and itd.brn = sca.branch_code
and itd.acc = sca.cust_ac_no
and itd.multimode_offset_brn is not null
and itd.multimode_tdoffset_acc is not null
then 1
else 0
end "NEW_ACC_FOR_THE_MONTH",
case when (trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
and trunc(sc.cif_creation_date,'MM') = trunc(p_applDate,'MM')
and not exists(select 1
from ictm_tdpayin_details itd
where itd.multimode_payopt = 'Y'
and itd.brn = sca.branch_code
and itd.acc = sca.cust_ac_no
and itd.multimode_offset_brn is not null
and itd.multimode_tdoffset_acc is not null
then 1
else 0
end "NEW_ACC_FOR_NEW_CUST",
(select 1 from dual
where exists(select 1
from ictm_td_closure_renew itcr
where itcr.brn = sca.branch_code
and itcr.acc = sca.cust_ac_no
and itcr.renewal_date = sysdate
or exists(select 1
from ictm_tdpayin_details itd
where itd.multimode_payopt = 'Y'
and itd.brn = sca.branch_code
and itd.acc = sca.cust_ac_no
and itd.multimode_offset_brn is not null
and itd.multimode_tdoffset_acc is not null
) "RENEWED_OR_ROLLOVER",
m.maturity_date "MATURITY_DATE",
sca.ac_stat_no_dr "DR_DISALLOWED",
sca.ac_stat_no_cr "CR_DISALLOWED",
-- sca.ac_stat_block "BLOCKED_ACC", --Not Reqd
sca.ac_stat_dormant "DORMANT_ACC",
sca.ac_stat_stop_pay "STOP_PAY_ACC", --New
sca.ac_stat_frozen "FROZEN_ACC",
sca.ac_open_date "ACC_OPENING_DT",
sca.address1 "ADD_LINE_1",
sca.address2 "ADD_LINE_2",
sca.address3 "ADD_LINE_3",
sca.address4 "ADD_LINE_4",
sca.joint_ac_indicator "JOINT_ACC",
sca.acy_avl_bal "CR_BAL",
0 "DR_BAL",
0 "CR_BAL_LCY", t
0 "DR_BAL_LCY",
null "YTD_CR_MOVEMENT",
null "YTD_DR_MOVEMENT",
null "YTD_CR_MOVEMENT_LCY",
null "YTD_DR_MOVEMENT_LCY",
null "MTD_CR_MOVEMENT",
null "MTD_DR_MOVEMENT",
null "MTD_CR_MOVEMENT_LCY",
null "MTD_DR_MOVEMENT_LCY",
'N' "BRANCH_TRFR", --New
sca.provision_amount "PROVISION_AMT",
sca.account_type "ACCOUNT_TYPE",
nvl(sca.tod_limit, 0) "TOD_LIMIT",
nvl(sca.sublimit, 0) "SUB_LIMIT",
nvl(sca.tod_limit_start_date, global.min_date) "TOD_START_DATE",
nvl(sca.tod_limit_end_date, global.max_date) "TOD_END_DATE"
from sttm_cust_account sca,
sttm_customer sc,
(select sca.cust_ac_no
sum(gf.limit_amount * (scal.linkage_percentage / 100)) +
case when p_applDate >= sca.tod_limit_start_date
and p_applDate <= nvl(sca.tod_limit_end_date, p_applDate)
then sca.tod_limit else 0
end
) dd
from sttm_cust_account sca
getm_facility gf,
sttm_cust_account_linkages scal
where gf.line_code || gf.line_serial = scal.linked_ref_no
and cust_ac_no = sca.cust_ac_no
group by sca.cust_ac_no
) w,
(select acc,
brn,
sum(decode(drcr,'D',amt)) dr_int,
sum(decode(drcr,'C',amt)) cr_int
from ictb_entries_history ieh
where ent_dt between p_st_dt and p_ed_dt
and drcr in ('C','D')
and liqn = 'Y'
and entry_passed = 'Y'
and exists(select null
from ictm_pr_int ipi,
ictm_rule_frm irf
where ipi.rule = irf.rule_id
and ipi.product_code = ieh.prod
and irf.book_flag = 'B'
group by acc,brn
) x,
(select acc,
brn,
sum(amt) fee_amt
from ictb_entries_history ieh
where ieh.ent_dt between p_st_dt and p_ed_dt
and exists(select product_code
from ictm_product_definition ipd
where ipd.product_code = ieh.prod
and ipd.product_type = 'C'
group by acc,brn
) y,
ictm_acc m,
(select sca.cust_ac_no,
sca.branch_code
coalesce(nvl2(coalesce(t1.ac_no,t1.ac_branch),'exists',null),
nvl2(coalesce(t2.account,t2.account),'exists',null),
nvl2(coalesce(t3.acc,t3.brn),'exists',null),
nvl2(coalesce(t4.cust_ac_no,t4.branch_code),'exists',null),
nvl2(coalesce(t5.cust_ac_no,t5.branch_code),'exists',null),
nvl2(coalesce(t6.cust_ac_no,t6.branch_code),'exists',null),
nvl2(coalesce(t7.cust_ac_no,t7.branch_code),'exists',null),
decode(sca.maker_dt_stamp,p_applDate,'exists'),
decode(sca.status_since,p_applDate,'exists')
) existence
from sttm_cust_account sca
left outer join
(select ac_no,ac_branch
from actb_daily_log
where trn_dt = p_applDate
and auth_stat = 'A'
) t1
on (sca.cust_ac_no = t1.ac_no
and sca.branch_code = t1.ac_branch
left outer join
(select account,account
from catm_amount_blocks
where effective_date = p_applDate
and auth_stat = 'A'
) t2
on (sca.cust_ac_no = t2.account
and sca.branch_code = t2.branch
left outer join
(select acc,brn
from ictm_td_closure_renew itcr
where renewal_date = p_applDate
) t3
on (sca.cust_ac_no = t3.acc
and sca.branch_code = t3.brn
left outer join
(select cust_ac_no,branch_code
from sttm_ac_stat_change
where status_change_date = p_applDate
and auth_stat = 'A'
) t4
on (sca.cust_ac_no = t4.cust_ac_no
and sca.branch_code = t4.branch_code
left outer join
(select cust_ac_no,branch_code
from cstb_acc_brn_trfr_log
where process_date = p_applDate
and process_status = 'S'
) t5
on (sca.cust_ac_no = t5.cust_ac_no
and sca.branch_code = t5.branch_code
left outer join
(select cust_ac_no,branch_code
from sttbs_provision_history
where esn_date = p_applDate
) t6
on (sca.cust_ac_no = t6.cust_ac_no
and sca.branch_code = t6.branch_code
left outer join
(select cust_ac_no,branch_code
from sttms_cust_account_dormancy
where dormancy_start_dt = p_applDate
) t7
on (sca.cust_ac_no = t7.cust_ac_no
and sca.branch_code = t7.branch_code
) z
where sca.branch_code = p_branch_code
and sca.cust_no = sc.customer_no
and sca.cust_ac_no = w.cust_ac_no
and sca.cust_ac_no = x.acc
and sca.branch_code = x.brn
and sca.cust_ac_no = y.acc
and sca.branch_code = y.brn
and sca.cust_ac_no = m.acc
and sca.branch_code = m.brn
and sca.cust_ac_no = z.sca.cust_ac_no
and sca.branch_code = z.branch_code
and z.existence is not nullRegards
Etbin -
Poor performance due to select query
Hey ppl,
I am facing a problem in one of the select query on BSEG.
The query is as given
TYPES :BEGIN OF wa1_bseg,
bukrs TYPE bseg-bukrs,
belnr TYPE bseg-belnr,
gjahr TYPE bseg-gjahr,
buzei TYPE bseg-buzei,
fwbas TYPE bseg-fwbas ,
pswbt TYPE bseg-pswbt,
hkont TYPE bseg-hkont,
wrbtr TYPE bseg-wrbtr,
ktosl TYPE bseg-ktosl,
koart TYPE bseg-koart,
shkzg TYPE bseg-shkzg,
mwskz TYPE bseg-mwskz,
qsskz TYPE bsis-qsskz,
dmbtr TYPE bseg-dmbtr,
flag TYPE C,
END OF wa1_bseg.
DATA: it_bsegv TYPE TABLE OF wa1_bseg WITH HEADER LINE.
SELECT bukrs belnr gjahr buzei fwbas pswbt hkont wrbtr ktosl shkzg koart mwskz
FROM bseg INTO TABLE it_bsegv
FOR ALL ENTRIES IN it_ekko
WHERE bukrs = 'MU51' AND
gjahr IN s_fiscal AND
valut IN s_budat1 AND
ebeln = it_ekko-ebeln.
Even if there are only around 5 records in it_ekko it takes very long time in executing. Sumtimes it even shows 'time out' in
foreground. Kindly help me out with itHi,
Go through this link it will helpful,
Re: Performance Issue with BKPF, BSEG, BSET
Re: Reading BSEG: performance problems
/people/rob.burbank/blog/2007/11/12/quickly-retrieving-fi-document-data-from-bseg
Regards
Adil
Edited by: Syed Abdul Adil on Jun 17, 2008 12:33 PM -
Performance problem whlile selecting(extracting the data)
i have one intermediate table.
iam inserting the rows which are derived from a select statement
The select statement having a where clause which joins a view (created by 5 tables)
The problem is select statement which is getting the data is taking more time
i identified the problems like this
1) The view which is using in the select statement is not indexed---is index is necessary on view ????
2) Because the tables which are used to create a view have already properly indexed
3) while extracting the data it is taking the more time
the below query will extract the data and insert the data in the intermediate table
SELECT 1414 report_time,
2 dt_q,
1 hirearchy_no_q,
p.unique_security_c,
p.source_code_c,
p.customer_specific_security_c user_security_c,
p.par_value par_value, exchange_code_c,
(CASE WHEN p.ASK_PRICE_L IS NOT NULL THEN 1
WHEN p.BID_PRICE_L IS NOT NULL THEN 1
WHEN p.STRIKE_PRICE_L IS NOT NULL THEN 1
WHEN p.VALUATION_PRICE_L IS NOT NULL THEN 1 ELSE 0 END) bill_status,
p.CLASS_C AS CLASS,
p.SUBCLASS_C AS SUBCLASS,
p.AGENT_ADDRESS_LINE1_T AS AGENTADDRESSLINE1,
p.AGENT_ADDRESS_LINE2_T AS AGENTADDRESSLINE2,
p.AGENT_CODE1_T AS AGENTCODE1,
p.AGENT_CODE2_T AS AGENTCODE2,
p.AGENT_NAME_LINE1_T AS AGENTNAMELINE1,
p.AGENT_NAME_LINE2_T AS AGENTNAMELINE2,
p.ASK_PRICE_L AS ASKPRICE,
p.ASK_PRICE_DATE_D AS ASKPRICEDATE,
p.ASSET_CLASS_T AS ASSETCLASS
FROM (SELECT
DISTINCT x.*,m.customer_specific_security_c,m.par_value
FROM
HOLDING_M m JOIN ED_DVTKQS_V x ON
m.unique_security_c = x.unique_security_c AND
m.customer_c = 'CONF100005' AND
m.portfolio_c = 24 AND
m.status_c = 1
WHERE exists
(SELECT 1 FROM ED_DVTKQS_V y
WHERE x.unique_security_c = y.unique_security_c
GROUP BY y.unique_security_c
HAVING MAX(y.trading_volume_l) = x.trading_volume_l)) p
any one please give me the valueble suggestions on the performancethanks for the updating
in the select query we used some functions like max
(SELECT 1 FROM ED_DVTKQS_V y
WHERE x.unique_security_c = y.unique_security_c
GROUP BY y.unique_security_c
HAVING MAX(y.trading_volume_l) = x.trading_volume_l)) p
will these type of functions will cause the performance problem ??? -
Problem in select query in QUERY INFOSET
Hi All
I have requirement to find the sales text maintained for sales order in mass in production. By using the FM READ_TEXT i can pass the necessary values to get the sales text. We dont want to write a program and then transprot to P01. So what i did in SQ02 i create a infoset and worte code in the infoset. Here i am facing the problem that in the select query where clause what ever on the selection screen values, for that the query need to fetch the records. But selection screen is dymically selected based on SQVI t-code.
In select query if i write like this
SELECT TDOBJECT TDNAME TDID TDSPRAS
FROM STXH
INTO TABLE IT_TEXT_DETAIL
WHERE TDOBJECT EQ C_KNMT .
Here i have hardcoded KNMT so it will fetch only that value irrespective of any values on the selection screen. How to get the values based on the selection screen. I debugged the query it automatically generates the code for selection screen which i am not able to pass in the program.
SAP has generated this code
select-options SP$00004 for STXH-TDOBJECT.
select-options SP$00005 for STXH-TDNAME.
select-options SP$00006 for STXH-TDID.
If i pass SP$00004 on where clause its giving me error. So how to pass it dynamically. Waiting for experts answer.
Regards
VijayHi Vijay,
In this case concatenate 'TDOBJECT' 'EQ' C_KNMT INTO V_WHERE (Say) SEPERATED BY SPACE.
DATA : v_where(90) type c.
clear v_where.
CONCATENATE 'TDOBJECT'
'EQ'
C_KNMT
INTO V_WHERE
SEPERATED BY SPACE.
SELECT TDOBJECT TDNAME TDID TDSPRAS
FROM STXH
INTO TABLE IT_TEXT_DETAIL
WHERE (V_WHERE) .
Try to do this and let me know in case of any.
Regards,
SRinivas -
Hi All,
i_dfkkko-xblnr
IF NOT i_dfkkko[] IS INITIAL .
SELECT opbel
belnr
FROM erchc
INTO TABLE i_erchc1
FOR ALL ENTRIES IN i_dfkkko
WHERE opbel EQ i_dfkkko-xblnr.
ENDIF.
I am using the above select query.problem is when i put the value
of i_dfkkko-xblnr by going to the table erchc i am getting the record.But this qury is not resulting any value.
i have checked in debug mode copied the value of xblnr of i_dfkkko
and went to erchc table and passed to opbel of erchc i got the reords.
can anybody pls help..
Rgds,
SaiHi,
The database would be having the value with leading zeroes.
Use FM "CONVERSION_EXIT_ALPHA_INPUT" to conver the values & then pass to select query.
_dfkkko-xblnr
IF NOT i_dfkkko[] IS INITIAL .
loop at i_dfkkko.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
VALUE(INPUT) = i_dfkkko-xblnr
IMPORITNG
VALUE(OUTPUT) = i_dfkkko-xblnr.
modify i_dfkkko.
endloop.
SELECT opbel
belnr
FROM erchc
INTO TABLE i_erchc1
FOR ALL ENTRIES IN i_dfkkko
WHERE opbel EQ i_dfkkko-xblnr.
ENDIF. -
Need pointers to improve performance of a select query to table vbrk
Hey Folks,
I have a query , whose performance needs to be tuned , as such:
SELECT a~vbeln
a~fkart
a~waerk
a~fkdat
b~posnr
b~vgbel
b~vgpos
b~matnr
b~arktx
b~prctr
b~txjcd
INTO TABLE gi_billing_items
FROM vbrk AS a
INNER JOIN vbrp AS b
ON a~vbeln = b~vbeln
FOR ALL ENTRIES IN gi_sales_items
WHERE b~vgbel = gi_sales_items-vbeln
AND b~vgpos = gi_sales_items-posnr
AND b~matnr = gi_sales_items-matnr
AND b~werks = gi_sales_items-werks.
where
gi_sales_items is an internal table consisting of 278 entries,.
The result set collected in table gi_billing_items is 200 records
The total execution time for this query for the afore given data is 72,983 ms with the average time/record being ~ 9,471 ms which is too high.
When I try to verify the Explain Plan of the query in ST05, in the Access path I see that the performance of Query Block 1 is bad. Query Block 1 is of the QBLOCK_TYPE UNIONA. Its the very first step in the Query execution internally.
The indexes are defined on participating tables VBRK and VBRP as:
VBRK~0 MANDT,VBELN
VBRK~LOC MANDT,LCNUM
VBRP~0 MANDT,VBELN,POSNR
VBRP~Z01 FPLNR,MANDT
VBRP~Z02 MANDT,MATNR,WERKS
Its clear from the ST05, STAD and SE30 traces that there is a performance issue in this query. Does anyone have any pointers as to how to resolve this issue? Is there a protocol one needs to follow when using the "FOR ALL ENTRIES IN" clause? Or is there a need for any secondary indexes to be created?
Please let me know
Thanks and Best Regards,
Rashmi.Hi,
Try using the VBFA...to get the Invoice number and line item..and then use that value in VBRK...
* Declare the internal table for T_VBFA.
IF NOT gi_sales_items[] IS INITIAL.
SELECT VBELV
POSNV
VBELN
POSNN
VBTYP_N
INTO TABLE T_VBFA
FOR ALL ENTRIES IN gi_sales_items
WHERE VBELV = gi_sales_items-VBELN
AND POSNV = gi_sales_items-POSNR
AND VBTYP_N = 'M'. "Invoice ""Added this..
ENDIF.
**Add two columns to GI_SALES_ITEMS..to store the VBELN POSNN the data from t_vbfa..let's assume it is VBELN_VF and POSNR_VF
* Basically merge gi_sales_items AND t_vbfa
** Then use that field in
IF NOT GI_SALES_ITEMS[] IS INITIAL.
SELECT a~vbeln
a~fkart
a~waerk
a~fkdat
b~posnr
b~vgbel
b~vgpos
b~matnr
b~arktx
b~prctr
b~txjcd
INTO TABLE gi_billing_items
FROM vbrk AS a
INNER JOIN vbrp AS b
ON a~vbeln = b~vbeln
FOR ALL ENTRIES IN gi_sales_items
WHERE b~vbeln = gi_sales_items-vbeln_vf " Change here
AND b~posnr = gi_sales_items-posnr_vf " Change here
AND b~matnr = gi_sales_items-matnr
AND b~werks = gi_sales_items-werks.
ENDIF.
Thanks
Naren
Edited by: Narendran Muthukumaran on Oct 15, 2008 11:35 PM -
Performance Problem with SQL Query
Hi
I have a SQL Query (say, SSS) which runs quite fast when I run it from TOAD.
But when the same query is being used as
INSERT INTO <table> VALUES <SSS>;
It is taking hours to complete.
The Original Query(OSQ) was changed to this SQL query(SSS) for Performance improvement.
The Cost has also improved quite a lot from OSQ to SSS. But when SSS runs from inside a procedure it is taking the same long hours as OSQ used to take.
Please help ASAP as it needs to get fixed.
Thanks
ArnabSELECT SRM.ID PROJECT_ID,
SRM.UNIQUE_NAME PROJECT_CODE,
ODFP.GS_FINANCE_PROJ_CODE,
ODFP.GS_PRODUCT_CODE,
ODFP.GS_CUSTOMER,
ODFP.GS_LEGAL_ENT_REF,
ODF_PRJ_TYPE.NAME GS_PROJ_TYPE,
ODF_SRC_SYS.NAME GS_SOURCE_SYSTEM,
RESM.FIRST_NAME||' '||RESM.LAST_NAME GS_PROJECT_MANAGER,
ODFP.GS_LEG_PROJ_NUM,
ODFP.GS_SUPP_DOC ,
ODFP.GS_REQUEST_ID ,
ODFP.GS_CONTRACT ,
ODFP.GS_SIEBEL_REF,
DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg)LAB_BDGT,
DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)NLI_BDGT,
(DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg))+(DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)) sum_lab_nonlab_budg,
frct.LABOUR,
frct.NON_LABOUR,
frct.LABOUR+frct.NON_LABOUR FORCAST_TOT_SUM,
gfr.code GFR_CODE,
odfp.gs_rev_recognition,
rev_rec.NAME gs_rev_recognition,
DECODE(odfp.gs_prevent_reqtxn,1,'YES','0','NO','NO'),
GS_PROGTYPE.NAME,
COMM_APPR.UNIQUE_NAME COMM_APPROVER_EIN,
COMM_APPR.FIRST_NAME||' '||COMM_APPR.LAST_NAME COMM_APPROVER_NAME,
PR_APPR.UNIQUE_NAME PR_APPROVER_EIN,
PR_APPR.FIRST_NAME||' '||PR_APPR.LAST_NAME PR_APPROVER_NAME,
ODFP.GS_BILL_BUD,
frct.FRCST_REVENUE TOTAL_FRC_REVENUE,
actuals.LABOUR_ACTUALS,
actuals.NL_ACTUALS,
-- get_wip_totalcost(prjp.prid,'L') LABOUR_ACTUALS,
-- get_wip_totalcost(prjp.prid,'M') NL_ACTUALS,
ODFP.GS_ASS_PRODUCT_CODE,
PROJ_TEMPLATE.ID GS_PROJ_TEMPLATE_ID,
PROJ_TEMPLATE.UNIQUE_NAME GS_PROJ_TEMPLATE_CODE,
PROJ_TEMPLATE.name GS_PROJ_TEMPLATE_NAME,
DECODE( NVL(ODFP.GS_FIN_TEMPLATE,0) ,0,'NO',1,'YES') GS_FIN_TEMPLATE,
ODF_PRJ_TYPE.LOOKUP_CODE GS_PROJ_TYPE
FROM PROJECTS SRM,
J_PROJECTS PRJP,
A_PROJECT ODFP,
RESOURCES RESM,
s_gfr gfr,
RESOURCES PROJ_ACCT,
RESOURCES COMM_APPR,
RESOURCES PR_APPR,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_PROJECT_TYPE'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_PRJ_TYPE,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_SOURCE_SYSTEM'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_SRC_SYS,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_PROG_TYPE'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS')GS_PROGTYPE,
(SELECT odf_parent_id
,SUM(gs_lab_budg) lab_budg
,SUM(gs_nl_budg) nli_budg
FROM T_CHANGES
WHERE gs_status='APPR'
GROUP BY odf_parent_id) budg,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_REV_RECOGNITION'
AND LOOKUP.ID = CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') rev_rec,
(SELECT FRCP1.project_id,
NVL(SUM(CASE WHEN srmr.resource_type=0 THEN for_val.cost ELSE NULL END),0) AS LABOUR,
NVL(SUM(CASE WHEN srmr.resource_type <> 0 THEN for_val.cost ELSE NULL END),0) AS NON_LABOUR,
NVL(SUM(for_val.revenue),0) AS FRCST_REVENUE
FROM T_PROPERTIES FRCP1,
T_DETAILS FOR_DET,
RESOURCES SRMR,
T_VALUES FOR_VAL
WHERE (FRCP1.project_id, revision) IN (SELECT project_id, MAX(revision)
FROM T_PROPERTIES FRCP
WHERE FRCP.status=2
AND FRCP.PERIOD_TYPE='SEMI_MONTHLY'
GROUP BY project_id)
AND FRCP1.PERIOD_TYPE='SEMI_MONTHLY'
AND FOR_DET.forecast_id=frcp1.id
AND SRMR.id(+)=FOR_DET.detail_id
AND FOR_VAL.currency_type='BILLING'
AND FOR_VAL.forecast_details_id=FOR_DET.ID
GROUP BY FRCP1.project_id) frct,
(SELECT srmp.id
,NVL(SUM(CASE WHEN wip.transtype='L' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS LABOUR_ACTUALS
,NVL(SUM(CASE WHEN wip.transtype='M' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS NL_ACTUALS
FROM A_WIP WIP
,om_periods biz
,P_VALUES WIPVAL
,PROJECTS SRMP
,A_PROJECT ODF
WHERE biz.period_type ='SEMI_MONTHLY'
AND TRUNC(wip.TRANSDATE) BETWEEN biz.start_date AND biz.end_date
AND WIP.TRANSNO=WIPVAL.TRANSNO
AND WIPVAL.CURRENCY_TYPE='BILLING'
AND SRMP.UNIQUE_NAME=WIP.PROJECT_CODE
AND SRMP.ID=ODF.ID
AND UPPER(ODF.partition_code)='GLOBAL'
AND UPPER(WIP.external_id) <> 'SPREADSHEET'
GROUP BY srmp.id) actuals,
RESOURCES BUD_HOLDER,
PROJECTS PROJ_TEMPLATE
WHERE SRM.ID = PRJP.PRID
AND ODFP.ID=PRJP.PRID
AND ODFP.PARTITION_CODE='GLOBAL'
AND RESM.id(+)=prjp.manager_id
AND ODFP.GS_PROJECT_TYPE = ODF_PRJ_TYPE.LOOKUP_CODE(+)
AND ODFP.GS_SOURCE_SYSTEM = ODF_SRC_SYS.LOOKUP_CODE(+)
AND ODFP.GS_prog_type = GS_PROGTYPE.LOOKUP_CODE(+)
AND budg.odf_parent_id(+)=SRM.ID
AND frct.project_id(+) = prjp.prid
AND ODFP.gs_risk_gfr=gfr.code(+)
AND ODFP.GS_REV_RECOGNITION=rev_rec.LOOKUP_CODE(+)
AND ODFP.GS_PROJ_ACCT = PROJ_ACCT.ID(+)
AND ODFP.GS_COMM_APPR = COMM_APPR.ID(+)
AND ODFP.GS_PR_APPR = PR_APPR.ID(+)
AND actuals.id(+) = prjp.prid -- Arnab
AND ODFP.GS_BUDGET_HOLDER=BUD_HOLDER.ID(+)
AND ODFP.GS_TEMPLATE_USED=PROJ_TEMPLATE.ID(+)
The above is OSQ with cost 45000. ... takes 1-1.5 hours through Toad
SELECT SRM.ID PROJECT_ID,
SRM.UNIQUE_NAME PROJECT_CODE,
ODFP.GS_FINANCE_PROJ_CODE,
ODFP.GS_PRODUCT_CODE,
ODFP.GS_CUSTOMER,
ODFP.GS_LEGAL_ENT_REF,
ODF_PRJ_TYPE.NAME GS_PROJ_TYPE,
ODF_SRC_SYS.NAME GS_SOURCE_SYSTEM,
RESM.FIRST_NAME||' '||RESM.LAST_NAME GS_PROJECT_MANAGER,
ODFP.GS_LEG_PROJ_NUM,
ODFP.GS_SUPP_DOC ,
ODFP.GS_REQUEST_ID ,
ODFP.GS_CONTRACT ,
ODFP.GS_SIEBEL_REF,
DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg)LAB_BDGT,
DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)NLI_BDGT,
(DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg))+(DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)) sum_lab_nonlab_budg,
frct.LABOUR,
frct.NON_LABOUR,
frct.LABOUR+frct.NON_LABOUR FORCAST_TOT_SUM,
gfr.code GFR_CODE,
odfp.gs_rev_recognition,
rev_rec.NAME gs_rev_recognition,
DECODE(odfp.gs_prevent_reqtxn,1,'YES','0','NO','NO'),
GS_PROGTYPE.NAME,
COMM_APPR.UNIQUE_NAME COMM_APPROVER_EIN,
COMM_APPR.FIRST_NAME||' '||COMM_APPR.LAST_NAME COMM_APPROVER_NAME,
PR_APPR.UNIQUE_NAME PR_APPROVER_EIN,
PR_APPR.FIRST_NAME||' '||PR_APPR.LAST_NAME PR_APPROVER_NAME,
ODFP.GS_BILL_BUD,
frct.FRCST_REVENUE TOTAL_FRC_REVENUE,
-- actuals.LABOUR_ACTUALS, -- Arnab
-- actuals.NL_ACTUALS, -- Arnab
get_wip_totalcost(prjp.prid,'L') LABOUR_ACTUALS, -- Arnab
get_wip_totalcost(prjp.prid,'M') NL_ACTUALS, -- Arnab
ODFP.GS_ASS_PRODUCT_CODE,
PROJ_TEMPLATE.ID GS_PROJ_TEMPLATE_ID,
PROJ_TEMPLATE.UNIQUE_NAME GS_PROJ_TEMPLATE_CODE,
PROJ_TEMPLATE.name GS_PROJ_TEMPLATE_NAME,
DECODE( NVL(ODFP.GS_FIN_TEMPLATE,0) ,0,'NO',1,'YES') GS_FIN_TEMPLATE,
ODF_PRJ_TYPE.LOOKUP_CODE GS_PROJ_TYPE
FROM PROJECTS SRM,
J_PROJECTS PRJP,
A_PROJECT ODFP,
RESOURCES RESM,
s_gfr gfr,
RESOURCES PROJ_ACCT,
RESOURCES COMM_APPR,
RESOURCES PR_APPR,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_PROJECT_TYPE'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_PRJ_TYPE,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_SOURCE_SYSTEM'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_SRC_SYS,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_PROG_TYPE'
AND LOOKUP.ID =CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS')GS_PROGTYPE,
(SELECT odf_parent_id
,SUM(gs_lab_budg) lab_budg
,SUM(gs_nl_budg) nli_budg
FROM T_CHANGES
WHERE gs_status='APPR'
GROUP BY odf_parent_id) budg,
(SELECT CAP.NAME
,LOOKUP.LOOKUP_CODE
FROM S_NLS CAP,
N_LOOKUPS LOOKUP
WHERE LOOKUP_TYPE ='GS_REV_RECOGNITION'
AND LOOKUP.ID = CAP.PK_ID
AND CAP.LANGUAGE_CODE='en'
AND CAP.TABLE_NAME = 'CMN_LOOKUPS') rev_rec,
(SELECT FRCP1.project_id,
NVL(SUM(CASE WHEN srmr.resource_type=0 THEN for_val.cost ELSE NULL END),0) AS LABOUR,
NVL(SUM(CASE WHEN srmr.resource_type <> 0 THEN for_val.cost ELSE NULL END),0) AS NON_LABOUR,
NVL(SUM(for_val.revenue),0) AS FRCST_REVENUE
FROM T_PROPERTIES FRCP1,
T_DETAILS FOR_DET,
RESOURCES SRMR,
T_VALUES FOR_VAL
WHERE (FRCP1.project_id, revision) IN (SELECT project_id, MAX(revision)
FROM T_PROPERTIES FRCP
WHERE FRCP.status=2
AND FRCP.PERIOD_TYPE='SEMI_MONTHLY'
GROUP BY project_id)
AND FRCP1.PERIOD_TYPE='SEMI_MONTHLY'
AND FOR_DET.forecast_id=frcp1.id
AND SRMR.id(+)=FOR_DET.detail_id
AND FOR_VAL.currency_type='BILLING'
AND FOR_VAL.forecast_details_id=FOR_DET.ID
GROUP BY FRCP1.project_id) frct,
/* (SELECT srmp.id
,NVL(SUM(CASE WHEN wip.transtype='L' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS LABOUR_ACTUALS
,NVL(SUM(CASE WHEN wip.transtype='M' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS NL_ACTUALS
FROM A_WIP WIP
,om_periods biz
,P_VALUES WIPVAL
,PROJECTS SRMP
,A_PROJECT ODF
WHERE biz.period_type ='SEMI_MONTHLY'
AND TRUNC(wip.TRANSDATE) BETWEEN biz.start_date AND biz.end_date
AND WIP.TRANSNO=WIPVAL.TRANSNO
AND WIPVAL.CURRENCY_TYPE='BILLING'
AND SRMP.UNIQUE_NAME=WIP.PROJECT_CODE
AND SRMP.ID=ODF.ID
AND UPPER(ODF.partition_code)='GLOBAL'
AND UPPER(WIP.external_id) <> 'SPREADSHEET'
GROUP BY srmp.id) actuals, */ -- Arnab
RESOURCES BUD_HOLDER,
PROJECTS PROJ_TEMPLATE
WHERE SRM.ID = PRJP.PRID
AND ODFP.ID=PRJP.PRID
AND ODFP.PARTITION_CODE='GLOBAL'
AND RESM.id(+)=prjp.manager_id
AND ODFP.GS_PROJECT_TYPE = ODF_PRJ_TYPE.LOOKUP_CODE(+)
AND ODFP.GS_SOURCE_SYSTEM = ODF_SRC_SYS.LOOKUP_CODE(+)
AND ODFP.GS_prog_type = GS_PROGTYPE.LOOKUP_CODE(+)
AND budg.odf_parent_id(+)=SRM.ID
AND frct.project_id(+) = prjp.prid
AND ODFP.gs_risk_gfr=gfr.code(+)
AND ODFP.GS_REV_RECOGNITION=rev_rec.LOOKUP_CODE(+)
AND ODFP.GS_PROJ_ACCT = PROJ_ACCT.ID(+)
AND ODFP.GS_COMM_APPR = COMM_APPR.ID(+)
AND ODFP.GS_PR_APPR = PR_APPR.ID(+)
AND actuals.id(+) = prjp.prid Arnab
AND ODFP.GS_BUDGET_HOLDER=BUD_HOLDER.ID(+)
AND ODFP.GS_TEMPLATE_USED=PROJ_TEMPLATE.ID(+)
This one in SSS where "-- Arnab " are only changes .....
The cost of this 7000.....finishes in 1 - 1.5 min in Toad
This is used as INSERT INTO TABLE <Select Query> ... this was taking 1.5 Hours to run.
It was changed using BULK COLLECT - still its taking around 1.5 hours to run...
Thanks
Arnab -
Performance problem in delete query
Hi,
I have to delete nearly 900 records from a table having 10 million records.
Each time I am deleting 100 of these records and calling this query from my
application many times. If I increase the rownum to 1000 then I get rollback
segment error due to limitation of user buffer.
Delete query is as follows
DELETE FROM try
WHERE DATEY2K<:b1
AND DATEY2K>0
AND ROWNUM<=100
where DATEY2K is a number field storin date information.
The TKPROF are as following
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 9 765.22 5705.34 1340105 1580307 27501 759
Fetch 0 0.00 0.00 0 0 0 0
total 9 765.22 5705.34 1340105 1580307 27501 759
Misses in library cache during parse: 0
Misses in library cache during execute: 1
Optimizer goal: FIRST_ROWS
Parsing user id: 14
Rows Execution Plan
0 DELETE STATEMENT GOAL: FIRST_ROWS
0 COUNT (STOPKEY)
0 TABLE ACCESS (BY ROWID) OF 'TRY'
0 INDEX (RANGE SCAN) OF 'ASH' (NON-UNIQUE)
The index ASH is on 2 columns of which first is DATEY2K.
Please advice/suggest to improve the performance of the above query.
Regards,
AshishWhat is the exact error message you are getting. It strikes me that if you cannot delete 900 records from any table, then your rollback is way too small.
Can you issue the query as a SELECT without the rownum?
John -
Performance of the select query
i want to know wheter the conversion of the select query
SELECT * FROM mchb
WHERE matnr EQ mch1-matnr
AND charg EQ mch1-charg
AND werks EQ plant-werks.
itab-lgort = mchb-lgort.
itab-clabs = mchb-clabs.
APPEND itab.
ENDSELECT.
into following pattern
select lgort clabs
from mchb
into corresponding fields of itab
WHERE matnr EQ mch1-matnr
AND charg EQ mch1-charg
AND werks EQ plant-werks.
ENDSELECT.
will give the same results ?Hi,
It will results in performance issue because of end select statement.
select lgort clabs
from mchb
into table itab
WHERE matnr EQ mch1-matnr
AND charg EQ mch1-charg
AND werks EQ plant-werks.
Use like this you will get the values of lgort and clabs in the internal table itab.
Then use loop statement to use that values further.
Dont use end select it will be a performance issue.
In this code there is no need to use of ENDSELECT and use corresponding fields of table itab.
select lgort clabs
from mchb
into corresponding fields of itab
WHERE matnr EQ mch1-matnr
AND charg EQ mch1-charg
AND werks EQ plant-werks.
ENDSELECT.
Thanks,
Sakthi -
Performance issue with select query
Hi friends ,
This is my select query which is taking so much time to retrive the records.CAn Any one help me in solving this performance issue.
*- Get the Goods receipts mainly selected per period (=> MKPF secondary
SELECT msegebeln msegebelp mseg~werks
ekkobukrs ekkolifnr ekkozterm ekkoekorg ekko~ekgrp
ekkoinco1 ekkoexnum
lfa1name1 lfa1land1 lfa1ktokk lfa1stceg
mkpfmblnr mkpfmjahr msegzeile mkpfbldat mkpf~budat
mseg~bwart
*Start of changes for CIP 6203752 by PGOX02
mseg~smbln
*End of changes for CIP 6203752 by PGOX02
ekpomatnr ekpotxz01 ekpomenge ekpomeins
ekbemenge ekbedmbtr ekbewrbtr ekbewaers
ekpolgort ekpomatkl ekpowebaz ekpokonnr ekpo~ktpnr
ekpoplifz ekpobstae
INTO TABLE it_temp
FROM mkpf JOIN mseg ON msegmblnr EQ mkpfmblnr
AND msegmjahr EQ mkpfmjahr
JOIN ekbe ON ekbeebeln EQ msegebeln
AND ekbeebelp EQ msegebelp
AND ekbe~zekkn EQ '00'
AND ekbe~vgabe EQ '1'
AND ekbegjahr EQ msegmjahr
AND ekbebelnr EQ msegmblnr
AND ekbebuzei EQ msegzeile
JOIN ekpo ON ekpoebeln EQ ekbeebeln
AND ekpoebelp EQ ekbeebelp
JOIN ekko ON ekkoebeln EQ ekpoebeln
JOIN lfa1 ON lfa1lifnr EQ ekkolifnr
WHERE mkpf~budat IN so_budat
AND mkpf~bldat IN so_bldat
AND mkpf~vgart EQ 'WE'
AND mseg~bwart IN so_bwart
AND mseg~matnr IN so_matnr
AND mseg~werks IN so_werks
AND mseg~lifnr IN so_lifnr
AND mseg~ebeln IN so_ebeln
AND ekko~ekgrp IN so_ekgrp
AND ekko~bukrs IN so_bukrs
AND ekpo~matkl IN so_matkl
AND ekko~bstyp IN so_bstyp
AND ekpo~loekz EQ space
AND ekpo~plifz IN so_plifz.
Thanks & Regards,
Manoj Kumar .Thatha
Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting and please use code tags when posting code - post locked
Edited by: Rob Burbank on Feb 4, 2010 9:03 AMHi friends ,
This is my select query which is taking so much time to retrive the records.CAn Any one help me in solving this performance issue.
*- Get the Goods receipts mainly selected per period (=> MKPF secondary
SELECT msegebeln msegebelp mseg~werks
ekkobukrs ekkolifnr ekkozterm ekkoekorg ekko~ekgrp
ekkoinco1 ekkoexnum
lfa1name1 lfa1land1 lfa1ktokk lfa1stceg
mkpfmblnr mkpfmjahr msegzeile mkpfbldat mkpf~budat
mseg~bwart
*Start of changes for CIP 6203752 by PGOX02
mseg~smbln
*End of changes for CIP 6203752 by PGOX02
ekpomatnr ekpotxz01 ekpomenge ekpomeins
ekbemenge ekbedmbtr ekbewrbtr ekbewaers
ekpolgort ekpomatkl ekpowebaz ekpokonnr ekpo~ktpnr
ekpoplifz ekpobstae
INTO TABLE it_temp
FROM mkpf JOIN mseg ON msegmblnr EQ mkpfmblnr
AND msegmjahr EQ mkpfmjahr
JOIN ekbe ON ekbeebeln EQ msegebeln
AND ekbeebelp EQ msegebelp
AND ekbe~zekkn EQ '00'
AND ekbe~vgabe EQ '1'
AND ekbegjahr EQ msegmjahr
AND ekbebelnr EQ msegmblnr
AND ekbebuzei EQ msegzeile
JOIN ekpo ON ekpoebeln EQ ekbeebeln
AND ekpoebelp EQ ekbeebelp
JOIN ekko ON ekkoebeln EQ ekpoebeln
JOIN lfa1 ON lfa1lifnr EQ ekkolifnr
WHERE mkpf~budat IN so_budat
AND mkpf~bldat IN so_bldat
AND mkpf~vgart EQ 'WE'
AND mseg~bwart IN so_bwart
AND mseg~matnr IN so_matnr
AND mseg~werks IN so_werks
AND mseg~lifnr IN so_lifnr
AND mseg~ebeln IN so_ebeln
AND ekko~ekgrp IN so_ekgrp
AND ekko~bukrs IN so_bukrs
AND ekpo~matkl IN so_matkl
AND ekko~bstyp IN so_bstyp
AND ekpo~loekz EQ space
AND ekpo~plifz IN so_plifz.
Thanks & Regards,
Manoj Kumar .Thatha
Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting and please use code tags when posting code - post locked
Edited by: Rob Burbank on Feb 4, 2010 9:03 AM
Maybe you are looking for
-
Message encode from mobile device
Message received encoded koi8-r was forwarded from a mobile device connected to Exchange 2010 with the header was encoded in windows-1251 and the message body in koi8-r and accordingly the recipient(user) could not read it. How can I fix these errors
-
Runtime Errors MOVE_TO_LIT_NOTALLOWED_NODATA
I am getting this error when i perform sum in ALV on particular field. Runtime Errors MOVE_TO_LIT_NOTALLOWED_NODATA Date and Time 08.05.2014 04:40:38
-
Can i stream for 2 apple tv so i mean 3 monitors
can i stream to 2 apple tvs i mean monitor 1 is the mac one and 2&3 are monitors
-
Update Billing Document During Credit Memo Creation
Hi, I need to update the billing document during credit memo creation in VA01. Is it possible to achieve this requirement since the billing document is in use during the runtime? Thanks & Regards, Mawi
-
Dynamically creating policies for Row-level security (RLS)
Hi everybody, I'm looking for suggestions on how to configure Row-level security (RLS). I have a large number of tables (about 500) and about 100 database users. Each user must see a portion of the data, filtered on a specific field. The field used t