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

SAP Performance Doubt -

Former Member
0 Likes
806

Dear All,

Can you please let me know, if I can use 'IN' instead of 'OR' in select statement. Also Let me know which one will have better performance.

here is code.

DATA: BEGIN OF ITAB OCCURS 0,

EBELN TYPE EKPO-EBELN,

EBELP TYPE EKPO-EBELP,

AEDAT TYPE EKPO-AEDAT,

MATNR TYPE EKPO-MATNR,

MENGE TYPE EKPO-MENGE,

END OF ITAB.

select EBELN EBELP AEDAT MATNR MENGE INTO TABLE ITAB

FROM EKPO

WHERE ( EBELN = '414001' OR

EBELN = '41200' ) .

or

select EBELN EBELP AEDAT MATNR MENGE INTO TABLE ITAB

FROM EKPO

WHERE EBELN IN ('414001','41200') .

will the two codes have same output.which code has better performance ?

Thank you.

Madhu

Moderator message - Moved to the correct forum

Edited by: Rob Burbank on May 27, 2009 2:30 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
778

Hi,

Check it in ST05

this will give you better performance

select EBELN EBELP AEDAT MATNR MENGE INTO TABLE ITAB

FROM EKPO

WHERE EBELN IN ('414001','41200') .

Regards

Krishna

7 REPLIES 7
Read only

Former Member
0 Likes
779

Hi,

Check it in ST05

this will give you better performance

select EBELN EBELP AEDAT MATNR MENGE INTO TABLE ITAB

FROM EKPO

WHERE EBELN IN ('414001','41200') .

Regards

Krishna

Read only

0 Likes
778

Krishna - you didn't follow your own advice, did you

Rob

Read only

HermannGahm
Product and Topic Expert
Product and Topic Expert
0 Likes
778

Hi Rob,

he maybe did by running the program once and traicing it.

If the OR was the first and the IN the second... and he compared

only the execution times... the IN is faster but not because of the IN

but because the OR statement is probably filling the db cache

and the IN statement is using it. If he would have run it multible times

and if he would have compared the execution planes he would have

seen that there is no difference between these two.

Kind regards,

Hermann

Read only

0 Likes
778

I agree with u. I have experienced it in the same way the if we just check it once the one when check 2nd is faster because it caches the data.

Nafran

Read only

Former Member
0 Likes
778

there is nearly no difference between the two variants, but still the one with the IN is recommended.

Differences are database dependent, and it can happen that the optimizers will give different estimates

for the two ... which makes only a difference if the clauses can together with others.

no performance issue, just a small recommendation.

One definite advantage, the IN is easier to read, if the number of choices becomes large.

Read only

0 Likes
778

Dear All,

Thank you for your replies.

I used SE30 to evaluate the performance of both statements. I agree with the point that first executed program takes more time. second executed program is using the cache and taking less time.

I am using 'IN' is my program as it is easy to read.

I am closing this thread and allotting points to all of you.

BUT, Honestly This is still not 100% answered.

Thank you.

Madhu.

Read only

former_member506713
Participant
0 Likes
778

IN will take less time as compared to OR u have used.

So better to go with IN.