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

Select statement- where!

Former Member
0 Likes
597

Hi,

In select statement, the where conditions could use 'IN select-range', while compare to IN (XX,FF,GG)/NOT IN((XX,FF,GG)), which is better on performance?

Thanks!

5 REPLIES 5
Read only

Former Member
0 Likes
569

Better performance is IN and if you use not in then you could get bad performance than in operator

Thanks

Seshu

Read only

Former Member
0 Likes
569

NOT will cause the database to do a full table scan. Imagine if you want to find a word in the dictionary and all you know is that the word is not "shoe".

It'd take a while.

Rob

Read only

Former Member
0 Likes
569

Always IN is much better than NOT IN.

Sri

Read only

Former Member
0 Likes
569

Hi Edgar

remember one point when your writing where condition

don't use negative conditions in the where condition like NOT etc..



if you use negative operations then the performance problem will get

so all way use positive conditions in the where condition


Selection Criteria


Restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code using CHECK statement. 
Select with selection list.

Points # 1/2

SELECT * FROM SBOOK INTO SBOOK_WA.
CHECK: SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
ENDSELECT.
The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list

SELECT CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
WHERE SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.


reward if usefull

Read only

Former Member
0 Likes
569

as far as optimization is concerned IN is better dan NOT IN ..