Application Development and Automation 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: 
Read only

Which is Faster

Former Member
0 Likes
1,385

Hello,

Which one is faster?

1. SELECT *

<b>INTO CORRESPONDING FIELDS OF TABLE W_TI_LQUA</b>

FROM ( LTBK AS C INNER JOIN LTBP AS B ON CTBNUM = BTBNUM )

WHERE BBESTQ ='Q' AND CMBLNR = WA_MBLNR.

or

2. SELECT f1 f2 f3

<b>INTO (W_TI_LQUA-f1, W_TI_LQUA-f2, W_TI_LQUA-f3)</b>

FROM ( LTBK AS C INNER JOIN LTBP AS B ON CTBNUM = BTBNUM )

WHERE BBESTQ ='Q' AND CMBLNR = WA_MBLNR.

Why?

Is it a way to improve this sql sentence performance??'

10nks!!

Gabriel

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,306

Hi,

<b>Option-2 is faster</b>. Since you are only reading the fields you are interested in, it reduce the network load and read will be fast. Also, when you use, INTO CORRESPONDING FIELDS OF TABLE, it is slower than INTO TABLE.

I would modify your second statement too. I assume that the structure of W_IT_LUQA is same as the fields you want to read from table.

2. SELECT f1 f2 f3

<b>INTO TABLE W_TI_LQUA</b>

FROM ( LTBK AS C INNER JOIN LTBP AS B ON CTBNUM = BTBNUM )

WHERE BBESTQ ='Q' AND CMBLNR = WA_MBLNR.

Regards,

RS

Hello,

Which one is faster?

1. SELECT *

<b>INTO CORRESPONDING FIELDS OF TABLE W_TI_LQUA</b>

FROM ( LTBK AS C INNER JOIN LTBP AS B ON CTBNUM = BTBNUM )

WHERE BBESTQ ='Q' AND CMBLNR = WA_MBLNR.

or

2. SELECT f1 f2 f3

<b>INTO (W_TI_LQUA-f1, W_TI_LQUA-f2, W_TI_LQUA-f3)</b>

FROM ( LTBK AS C INNER JOIN LTBP AS B ON CTBNUM = BTBNUM )

WHERE BBESTQ ='Q' AND CMBLNR = WA_MBLNR.

Why?

Is it a way to improve this sql sentence performance??'

10nks!!

Gabriel

7 REPLIES 7
Read only

Former Member
0 Likes
1,307

Hi,

<b>Option-2 is faster</b>. Since you are only reading the fields you are interested in, it reduce the network load and read will be fast. Also, when you use, INTO CORRESPONDING FIELDS OF TABLE, it is slower than INTO TABLE.

I would modify your second statement too. I assume that the structure of W_IT_LUQA is same as the fields you want to read from table.

2. SELECT f1 f2 f3

<b>INTO TABLE W_TI_LQUA</b>

FROM ( LTBK AS C INNER JOIN LTBP AS B ON CTBNUM = BTBNUM )

WHERE BBESTQ ='Q' AND CMBLNR = WA_MBLNR.

Regards,

RS

Read only

Former Member
0 Likes
1,306

select into corresponding is slower, Try to avoid as much as possible. To imporve the performance u should hit all key fields.

Read only

Former Member
0 Likes
1,306

Hi,

the second statement is faster because:

its only selects the desired number of colums which reduces network traffic on the server. its also mentions the destination field names, so it becomes easy to map from source to destination.

Reward points if useful.

regards

vivek

Read only

Former Member
0 Likes
1,306

Hi

the 2nd option is faster cuz of:

1.selecting only the required fields

2. avoiding INTO CORRESPONDING fields.

yes, it will definitely improve the performance.

Regards,

Madhumitha

Read only

Former Member
0 Likes
1,306

Hai Gabriel Fernand,

AS into corresponding fields of option internally uses loops and so many comparisions,It works very slowly compared to second option.

So Socond option is better.

Hope you got some more reasons.

Reward points if it helps you.

Regds,

Rama chary.Pammi

Read only

Former Member
0 Likes
1,306

Hi,

second statement is better as it selects only required fields.

Reward if useful.

Thanks,

USR

Read only

Former Member
0 Likes
1,306

It doesn't matter which statement is faster. Both will be slow until you add LGNUM into the JOIN condition:


SELECT f1 f2 f3
  INTO (w_ti_lqua-f1, w_ti_lqua-f2, w_ti_lqua-f3)
  FROM ( ltbk AS c INNER JOIN
         ltbp AS b ON
           c~lgnum = b~lgnum  AND
           c~tbnum = b~tbnum )
  WHERE b~bestq ='Q' AND c~mblnr = wa_mblnr.

Rob