DB2-z/OS: Bad performance in VA01 for the access of ATP_RESB
Symptom
Performance problems creating sales order using VA01. The problem is the SELECT on ATP_RESB in LATP2FR1:
ENHANCEMENT-SECTION RESB_DB_READ_01 SPOTS ES_SAPLATP2.
SELECT *
FROM atp_resb
INTO atp_resb
WHERE matnr = atpmat-matnr
AND werks = atpmat-werks
AND xloek = space
AND kzear = space
AND bdter < atpmat-endwz
AND bdart <> skbed
…
DB2 is using index RESB~0 instead of index RESB~M.
Reason and Prerequisites
Due to the REOPT(ONCE) feature of DB2 the access path depends on the first set of values used. If this set is not typical a wrong access path might be determined and stored in the DB2 dynamic statement cache. In the case here a non-uniform data distribution between several clients is causing the problem.
Solution
Adding a CTE hint will enforce the desired access path regardless of the set of values used for preparing the statement. This solution will be used until the REOPT(AUTO) feature of DB2 V9 can be used by SAP.
DB2 ZPARM OPTHINTS must be set to YES for DB2 V8. In DB2 V9 CTE hints can be used regardless of the setting of OPTHINTS.