‎2009 Jul 31 6:08 AM
hi gurus,
iam using one select query with joins... but it fetches data from table that having lakhs of data... so the query is giving performance issue, so what select query i will write to solve this issue...
THE CODE IS IS GIVEN BELOW
SELECT ABLDAT ABUDAT ACPUDT BMATNR SUM( BMENGE ) BBWART
INTO TABLE ITAB FROM MKPF AS A
INNER JOIN
MSEG AS B
ON BMBLNR = AMBLNR AND BMJAHR = AMJAHR
WHERE A~BLDAT IN ZDATE AND
B~BWART IN ('131', '132') AND
B~LGORT = 'FG01' AND
BKZBEW = 'F' GROUP BY ABLDAT ABUDAT ACPUDT BMATNR BBWART.
LOOP AT ITAB.
CNT = CNT + 1.
ITAB2-CNT = CNT.
ITAB2-BLDAT = ITAB-BLDAT.
ITAB2-BUDAT = ITAB-BUDAT.
ITAB2-CPUDT = ITAB-CPUDT.
ITAB2-MATNR = ITAB-MATNR.
ITAB2-MENGE = ITAB-MENGE.
ITAB2-BWART = ITAB-BWART.
‎2009 Jul 31 12:32 PM
Check you may use the view: WB2_V_MKPF_MSEG2. This may save you from joining two tables.
Use for all entries instead of join.
Try and compare the two select queries through a trace ST05.
I have seen the Select for all entries is far better in performance.
Edited by: jaya rangwani on Jul 31, 2009 1:33 PM
‎2009 Jul 31 12:32 PM
Check you may use the view: WB2_V_MKPF_MSEG2. This may save you from joining two tables.
Use for all entries instead of join.
Try and compare the two select queries through a trace ST05.
I have seen the Select for all entries is far better in performance.
Edited by: jaya rangwani on Jul 31, 2009 1:33 PM
‎2009 Jul 31 12:33 PM
Hi Manish,
Use FOR ALL ENTRIES. It is much more efficient.
Regards,
Premal
‎2009 Jul 31 6:47 PM
check for indexes in the table and if any index matches your where condition then use it in the same sequence.