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

Sequential Read on BSAD

Former Member
0 Likes
663

Why would the following select statement not use the primary key and instead be read sequentially?

SELECT bsadbukrs bsadkunnr bsadshkzg bsaddmbtr FROM bsad

APPENDING corresponding fields of table tbsad

WHERE bsad~mandt EQ sy-mandt

AND bsad~bukrs EQ g_bukrs

AND bsad~kunnr IN kunnr

AND bsad~umsks IN r_umsks

AND bsad~umskz IN r_umskz.

4 REPLIES 4
Read only

ThomasZloch
Active Contributor
0 Likes
626

Depends on how range KUNNR is filled. If it is empty or has wide ranges, the systems needs to scan the whole table, because at some point (percentage of rows requested in relation to total number of rows), a full table scan becomes more efficient than using key access.

By the way, selection on MANDT without CLIENT SPECIFIED does not make sense to me.

Thomas

Read only

Former Member
0 Likes
626

The full primary key isn't being used - but I think the main reason is that it depends what is in the IN ranges that are being used. I don't they're necessary parsed into direct reads...

Read only

Former Member
0 Likes
626

Because you have included the client in the WHERE, but not used CLIENT SPECIFIED. Try it this way:

SELECT bsad~bukrs bsad~kunnr bsad~shkzg bsad~dmbtr
   FROM bsad
  APPENDING CORRESPONDING FIELDS OF TABLE tbsad
  WHERE bsad~bukrs EQ g_bukrs
    AND bsad~kunnr IN kunnr
    AND bsad~umsks IN r_umsks
    AND bsad~umskz IN r_umskz.

Rob

Read only

Former Member
0 Likes
626

Thanks for the feedback.