Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Bad Performance of the Query

0 Kudos

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

1 ACCEPTED SOLUTION

yogendra_bhaskar
Contributor
0 Kudos

Hi Ravi,

Use join of MKPF and MSEG on MBLNR and MJAHR , instead of using sub query

regards,

Yogendra Bhaskar

4 REPLIES 4

yogendra_bhaskar
Contributor
0 Kudos

Hi Ravi,

Use join of MKPF and MSEG on MBLNR and MJAHR , instead of using sub query

regards,

Yogendra Bhaskar

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

Why use WB2_V_MKPF_MSEG2 when you can directly use MKPF and MSEG in the join select query?