Skip to Content
0
Former Member
Jun 26, 2009 at 12:35 PM

Which index will DB use for the select statement?

63 Views

HI,

I have this code (from IW47):

SELECT * FROM afru INTO TABLE lt_conf

FOR ALL ENTRIES IN lt_task

WHERE rueck = lt_task-rueck

AND pernr IN pernr_c

AND ersda IN ersda_c

AND ernam IN ernam_c

AND budat IN budat_c

AND werks IN werks_c

AND arbid IN arbid_c

AND aueru IN aueru_c

AND grund IN grund_c

AND loart IN loart_c

AND learr IN learr_c

AND isdd IN isdd_c

AND isdz IN isdz_c

AND iedd IN iedd_c

AND iedz IN iedz_c

AND stzhl IN gr_stzhl

AND stokz IN gr_stokz.

And AFRU has 1 custom index (aside from the pre-existing index) with the ff fields in order:

MANDT

WERKS

AUFNR

Currently, the system uses the index above which causes the program to run slow...

I want to create an index with only the ff. fields:

MANDT

BUDAT

WERKS

Will the system use the index I will create instead of the first index?

Of all the fields in the where conditions in the select from AFRU only budat_c and werks_c will always have values...

Please advice...

Thanks!