07-04-2012 12:53 PM
Bad Performance of the Query..
How can we improve the performance with following query.
Please suggest.
SELECT MBLNR
BUDAT
BWART_I
MATNR_I
WERKS_I
LGORT_I
SHKZG_I
MENGE_I
XAUTO_I
FROM WB2_V_MKPF_MSEG2
INTO TABLE T_MSEG
WHERE MBLNR IN ( SELECT MBLNR FROM MKPF WHERE BUDAT BETWEEN '20120401' AND SY-DATUM ).
Thanks.
Ravi
07-04-2012 1:01 PM
Hi Ravi,
Use join of MKPF and MSEG on MBLNR and MJAHR , instead of using sub query
regards,
Yogendra Bhaskar
07-04-2012 1:01 PM
Hi Ravi,
Use join of MKPF and MSEG on MBLNR and MJAHR , instead of using sub query
regards,
Yogendra Bhaskar
07-04-2012 1:09 PM
and by the way , what is the use of using a sub query in where condition ?
This code will serve the purpose :
SELECT MBLNR
BUDAT
BWART_I
MATNR_I
WERKS_I
LGORT_I
SHKZG_I
MENGE_I
XAUTO_I
FROM WB2_V_MKPF_MSEG2
INTO TABLE T_MSEG
WHERE BUDAT BETWEEN '20120401' AND SY-DATUM .
regards ,
Yogendra Bhaskar
07-05-2012 5:49 AM
Hi,
If you cannot avoid the subquery then use it. By the way using sub query is efficient than using nested select queries or for all entries in.
You may verify the same by following the below mentioned path:
SE30 -> Tips and Tricks -> SQL Interface -> Select over more than one table -> Using sub queries.
Hope it helps you.
Thanks and regards,
Kartik
07-05-2012 5:35 AM
Why use WB2_V_MKPF_MSEG2 when you can directly use MKPF and MSEG in the join select query?