Indexes for Popular SAP Tables

I've discovered after talking to someone in database technical support here at M.I.T. that the reason the following statement is true:

"To choose an index, the optimizer looks at the field names in the where clause and then it looks for an index having the same field names in the same order as they were specified in the where clause. Therefore, to ensure the system chooses the index you intend, specify the fields in the where clause in the same order as they appear in the index.... If a table begins with MANDT and an index doesn't, the optimizer might not use the index." (from Teach Yourself ABAP/4 in 21 Days by Ken Greenwood)

is that a lot of popular database engines are "rule based" instead of "cost based". M.I.T. is investigating converting to a "cost based" optimizer. This means that a lot of our "rules based" where clauses might become very inefficient. Others will become more efficient.

FI Tables (BKPF & BSEG & BSID & BSAD)

Any FI index using BELNR can be restricted by Document Type. Each Document Type is associated with a number range. See SAP transparent table NRIV.

BKPF

Unique index BKPF______0
MANDT
BUKRS 'CUR '
BELNR
GJAHR

 

Index BKPF______1
MANDT
BUKRS 'CUR '
BSTAT space
XBLNR

 

Index BKPF______2
MANDT
BUKRS 'CUR '
BSTAT space
BUDAT

 

Index BKPF______3
MANDT
BUKRS 'CUR '
BSTAT space
BLART

 

Index BKPF______4
MANDT
AWTYP
AWKEY
AWSYS

 

Index BKPF______5
MANDT
BUKRS 'CUR '
CPUDT
BSTAT space

 

Index BKPF______6
MANDT
BUKRS 'CUR '
BLDAT
BSTAT space

 

BSEG
(clustered table)

Primary Index for BSEG:
MANDT
BUKRS 'CUR '
BELNR
GJAHR
BUZEI

BSID

Unique index BSID___0
MANDT
BUKRS
KUNNR
UMSKS
UMSKZ
AUGDT
AUGBL
ZUONR
GJAHR
BELNR
BUZEI 

Index BSID___1
MANDT
KUNNR
BUKRS
GJAHR
BELNR
BUZEI

BSAD

Unique index BSAD___0
MANDT
BUKRS
KUNNR
UMSKS
UMSKZ
AUGDT
AUGBL
ZUONR
GJAHR
BELNR
BUZEI 

Index BSAD___1
MANDT
KUNNR
BUKRS
AUGDT
AUGBL
GJAHR
BELNR
BUZEI

CO Tables (COSS, COSP, COBK, COEP, COVP)

Any CO index using BELNR can be restricted by Transaction Code. Each Document Type is associated with a number range. See SAP transparent table NRIV.

COSS
COSP

Unique index COSS___0
MANDT
LEDNR '00'
OBJNR
GJAHR
WRTTP 31, 03-12
VERSN '000'
KSTAR
HRKFT space
VRGNG
PAROB
USPOB
BEKNZ
TWAER
PERBL

Index COSS___1
OBJNR
MANDT
LEDNR '00'
VERSN '000'
WRTTP 31, 03-12
GJAHR
VRGNG

 

COBK

Unique index COBK___0
MANDT
KOKRS 'MIT '
BELNR

Index COBK___O
REFBT
REFBN
KOKRS 'MIT '
REFBK
REFGJ

For cost overrun documents that have not been reversed the values of these columns are:

REFBT space
REFBN space
KOKRS 'MIT '
REFBK space
BELNR '0200000000' - '0399999999'
VRGNG 'RKU1'
STOKZ <> 'X'

COEP

Unique index COEP______0
|MANDT
KOKRS 'MIT '
BELNR
BUZEI

Index COEP______1
MANDT
LEDNR '00'
OBJNR
GJAHR
WRTTP 31, 03-12
VERSN '000'
KSTAR
HRKFT space
PERIO
VRGNG
PAROB
USPOB
VBUND
PARGB
BEKNZ
TWAER

COVP

COVP is a view that joins COEP & COBK. It uses the same indexes as the underlying tables. Use it when you want to access columns from both tables.

Open Item Managment (COOI)

COOI

Unique index COOI___0
MANDT
REFBT
REFBN
RFPOS
RFKNT
RFTRM
RFART
LIFNR
LEDNR
OBJNR
HRKFT

Index COOI___1
MANDT
LEDNR '00'
OBJNR
GJAHR
WRTTP '22'
VERSN '000'
SAKTO
HRKFT space
VRGNG 'RMBE'
VBUND
PARGB
BEKNZ
TWAER

SD Tables (M_ZSB21, ...)

Sales Document match code (M_ZSB21)

MANDT
VBELN
POSNR
PS_PSP_PNR
PSTYV
ERDAT