cancel
Showing results for 
Search instead for 
Did you mean: 

Query Optimization?

koushikking
Explorer
0 Kudos

Hi All,

I have simple queries like following.

SELECT VBELN

              POSNR

              MATNR

              ERDAT

         INTO TABLE  LT_VBRP_OR

         FROM  VBRP

         FOR ALL ENTRIES IN LT_POPIN_N

         WHERE MATNR EQ LT_POPIN_N-MATNR.

     SELECT VBELN

                   POSNR 

                   MATNR

                   AEDAT

         INTO TABLE LT_LIPS_OR

         FROM LIPS

         FOR ALL ENTRIES IN LT_POPIN_N

         WHERE MATNR EQ LT_POPIN_N-MATNR.

each query taking about 20 seconds to process. LT_POPIN_N may contain maximum of 5 records.

Am facing too much performance problem. Please anyone guide me in an optimized way.

Accepted Solutions (1)

Accepted Solutions (1)

Ajit_K_Panda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi koushik,

Please check for secondary indexes in the table and try to make the where condition bases on secondary indexes or primary key fields. You can also create secondary indexes as needed in the tables.

Regards,
Ajit

koushikking
Explorer
0 Kudos

Hi Ajit,

Is this right way to do?

SELECT VBELN

            POSNR 

            MATNR

            AEDAT

         INTO TABLE LT_LIPS_OR

         FROM LIPS

         FOR ALL ENTRIES IN LT_POPIN_N

         WHERE MATNR EQ LT_POPIN_N-MATNR

         %_HINTS ORACLE 'INDEX("LIPS" "LIPS~MAT")'.

Ajit_K_Panda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Koushik,

You dont need to mention secondary index. it will be automatically be taken up by SAP.

SELECT   VBELN

                   POSNR

                   MATNR

                   AEDAT

      INTO   TABLE LT_LIPS_OR

      FROM LIPS

      FOR     ALL ENTRIES IN LT_POPIN_N

      WHERE MATNR EQ LT_POPIN_N-MATNR.

This should work. 

Answers (0)