QUOTE(castelloz @ Jul 2 2009, 02:29 PM)
Guys,
Junior abaper need help here.
How do I improve the performance of this coding?
SELECT ltap~tanum ltap~nlpla ltap~wdatu INTO (ltap-tanum, ltap-nlpla, ltap-wdatu)
UP TO 1 ROWS
FROM ltap INNER JOIN lagp
ON lagp~lgnum = ltap~lgnum
AND lagp~lgtyp = ltap~nltyp
AND lagp~lgpla = ltap~nlpla
WHERE lagp~skzue = ' '
AND ltap~pquit = 'X'
AND ltap~matnr = ls_9001_scrn-matnr
AND ltap~lgort = ls_9001_scrn-to_lgort
AND ltap~lgnum = ls_9001_scrn-lgnum
AND ltap~nltyp = ls_9001_scrn-nltyp
ORDER BY tanum DESCENDING.
ENDSELECT.
IF sy-subrc EQ 0.
ls_9001_scrn-nlpla = ltap-nlpla.
EXIT.
ENDIF.
With this conditions:
1)I only 1 to get 1 record.
2)I need to get the record by latest tanum (Transfer Order No)
2)The LTAP table has 10K records. Even u go to SE16, just click No of records button, it took about 35 secods before show the result. So SELECT INTO TABLE lt_ltap then only sort in application server actually takes longer time.
3)INNER JOIN must be used, else for sure will take longer.
The index for the table is enough for the sql.
-create secondary indexes in the table to improve reading speed on non-key fields.Junior abaper need help here.
How do I improve the performance of this coding?
SELECT ltap~tanum ltap~nlpla ltap~wdatu INTO (ltap-tanum, ltap-nlpla, ltap-wdatu)
UP TO 1 ROWS
FROM ltap INNER JOIN lagp
ON lagp~lgnum = ltap~lgnum
AND lagp~lgtyp = ltap~nltyp
AND lagp~lgpla = ltap~nlpla
WHERE lagp~skzue = ' '
AND ltap~pquit = 'X'
AND ltap~matnr = ls_9001_scrn-matnr
AND ltap~lgort = ls_9001_scrn-to_lgort
AND ltap~lgnum = ls_9001_scrn-lgnum
AND ltap~nltyp = ls_9001_scrn-nltyp
ORDER BY tanum DESCENDING.
ENDSELECT.
IF sy-subrc EQ 0.
ls_9001_scrn-nlpla = ltap-nlpla.
EXIT.
ENDIF.
With this conditions:
1)I only 1 to get 1 record.
2)I need to get the record by latest tanum (Transfer Order No)
2)The LTAP table has 10K records. Even u go to SE16, just click No of records button, it took about 35 secods before show the result. So SELECT INTO TABLE lt_ltap then only sort in application server actually takes longer time.
3)INNER JOIN must be used, else for sure will take longer.
The index for the table is enough for the sql.
-create a view (joining both tables) to improve readability, then using a select single
Jul 3 2009, 12:47 AM

Quote
0.0418sec
0.71
7 queries
GZIP Disabled