Quantcast
Channel: SCN : All Content - ABAP for SAP HANA
Viewing all articles
Browse latest Browse all 831

Performance Tuning Example 2(using a 'For All Entries' statement )

$
0
0

Source code below is an example of using the 'For All Entries' statement


REPORT ZHIS_TUN_002_BEFORE.

 

DATA: IT_COEP TYPE TABLE OF COEP,

           IT_COBK TYPE TABLE OF COBK.

 

SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_COBK

FROM COBK.

 

SELECT *

FROM  COEP INTO CORRESPONDING FIELDS OF TABLE IT_COEP

             FOR ALL ENTRIES IN IT_COBK

WHERE KOKRS = IT_COBK-KOKRS

AND BELNR = IT_COBK-BELNR.

 

WRITE:/ LINES( IT_COEP ).



The results of analysis of the source code of the above in RUNTIME ANALYSIS are as follows:



img_2_1.JPG


It took most of the work time in the ‘DB: OPEN’ and ‘DB: Fetch’

but 'DB: Fetch' time can not improve because the amount of data transferred is large.

 

 

Double-click the ‘DB: OPEN’, check the HIT LIST

 

img_2_2.JPG

If the data is large, 'For All Entries' may be generated many DB access.

 

As a result, It can be confirmed that the execution time is slow

 

 

The following is the source code that uses the JOIN in order to improve this.

 

REPORT ZHIS_TUN_002_AFTER.

 

DATA: IT_COEP TYPE TABLE OF COEP ,

           IT_COBK TYPE TABLE OF COBK .

 

SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_COEP

FROM  COEP AS A INNER JOIN COBK AS B

                        ON B~KOKRS = A~KOKRS AND B~BELNR = A~BELNR.

 

WRITE:/ LINES( IT_COEP ) .

 

 

img_2_3.JPG

 

img_2_4.JPG

 

Because there was a 'COEP' table only once access, you can see that the execution time is greatly reduced.

(DB:OPEN Runtime : 14,103,513 -> 752)

 

If the data is large , do not the 'For All Entries' and Use 'JOIN' or 'SUBQUERY' can improve performance.


Viewing all articles
Browse latest Browse all 831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>