Application Development 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: 

Order of fields in Primary key in where clause

Former Member
0 Kudos

Hello,

Does order of fields(complete primary key) in where condition matters with the performance or using of index ?

Here is an example -

BKPF has primary key - bukrs, gjahr, belnr.

1. select single awkey into lv_awkey

from bkpf where bukrs = p_bukrs

and gjahr = p_gjahr

and belnr = p_belnr.

2. select single awkey into lv_awkey from bkpf

where bukrs = p_bukrs and

belnr = p_belnr and

gjahr = p_gjahr.

Does it make any difference in performance point of view with above two kinds ? Is that same applicable when accessing based on secondary index ?

Thanks,

Nagarjuna

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos

using all the primary key / index is performance oriented approach.. order does not matter.

3 REPLIES 3

former_member156446
Active Contributor
0 Kudos

using all the primary key / index is performance oriented approach.. order does not matter.

Former Member
0 Kudos

Welcome to SCN. As said, the order does not matter. But you can test this yourself, by running a performance trace (transaction ST05) and checking the explain for both versions of the SELECT.

Rob

former_member192616
Active Contributor
0 Kudos

Hi Nagarjuna,

the order of the fields does not influence the performance of the execution of the statements. This is true for primary key and secondary key accesses. In the statement cache (SAP and DB) two different statemens have to be maintained (parsing, space, ...) but their execution time is the same.

Kind regards,

Hermann