‎2009 Jun 10 3:00 AM
I have a question sequence of field in select statement is impact with performance or not ? Please see the two select statement as below.
DATA: l_bukrs TYPE bkpf-bukrs,
l_belnr TYPE bkpf-belnr,
l_gjahr TYPE bkpf-gjahr,
l_blart TYPE bkpf-blart.
PARAMETERS: p_bukrs TYPE bkpf-bukrs,
p_belnr TYPE bkpf-belnr,
p_gjahr TYPE bkpf-gjahr.
SELECT bukrs belnr gjahr blart
INTO (l_bukrs,l_belnr,l_gjahr,l_blart)
FROM bkpf
WHERE bukrs = p_bukrs
AND belnr = p_belnr
AND gjahr = p_gjahr.
ENDSELECT.
This select statement is low performance if comparing with above select statement
SELECT blart gjahr belnr bukrs
INTO (l_blart,l_gjahr,l_belnr,l_bukrs)
FROM bkpf
WHERE bukrs = p_bukrs
AND belnr = p_belnr
AND gjahr = p_gjahr.
ENDSELECT.
‎2009 Jun 10 3:12 AM
Hi veeraphol theamthong-on,
First of all as You Would know Using SELECT and ENDSELECT is not a good practise (Its similar to We are fetching data from BKPF in a loop).
We should Fetch data from BKPF in to a Internal Table and then process with our logic.
SELECT bukrs belnr gjahr blart
INTO (l_bukrs,l_belnr,l_gjahr,l_blart)
FROM bkpf
WHERE bukrs = p_bukrs
AND belnr = p_belnr
AND gjahr = p_gjahr.
ENDSELECT.
* This select statement is low performance if comparing with above select statement
" Yes because missing in the sequence of Key Fields.
SELECT blart gjahr belnr bukrs
INTO (l_blart,l_gjahr,l_belnr,l_bukrs)
FROM bkpf
WHERE bukrs = p_bukrs
AND belnr = p_belnr
AND gjahr = p_gjahr.
ENDSELECT.Regards,
Suneel G
‎2009 Jun 10 3:46 AM
Hi Veeraphol,
You Should use the fields of a table in the Select statement in a sequence order to have a better Performance.
Depeding upon the requirement we can use the Select & Endselect Loop...
Thanks & regards,
Dileep .C
‎2009 Jun 10 4:37 AM
‎2009 Jun 10 4:42 AM
‎2009 Jun 10 4:47 AM
Hi,
You should not use Select and end select.. And for better performance you should select in the same sequence as in the database... To check the performance of your program goto transaction SE30->Give your program name and click on execute. Then execute your program completely once. Go back and then click on the 'Analyze' Button. You will be able to see the performance of your program.
Thanks,
Sneha.
‎2009 Jun 10 5:41 AM
Hi Veeraphol,
You can check the Performance trace at ST05 or in SE30 Tcodes...
Also look for the documentation in SE30 for a good performance usage Guides,,,
Thanks & regards,
Dileep .C
‎2009 Jun 10 3:55 AM
You must not use the select - endselect phrase for a system performence.
If you use the phrase, the system contects DB item by item.
It means the number of the commuting between application layer and dblayer is the same as the number of selected items.
Insted of doing this, you'd like to use select phrase with where phrase.
then you can minimize the commuting number. and it makes your system performance better.
regards,
Jonghwan
Edited by: JONG HWAN PARK on Jun 10, 2009 4:55 AM