‎2008 Oct 22 3:09 PM
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.
‎2008 Oct 22 3:15 PM
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
‎2008 Oct 22 3:15 PM
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...
‎2008 Oct 22 3:17 PM
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
‎2008 Oct 22 3:23 PM