Hi developers,
we encountered a performance issue in a managed RAP scenario. In our usecase a large set of around 100.000 records with 19 columns is updated through a RAP action. Only 3 of the 19 columns are changed during the action and we mark these columns in the %control structure for each record. Our system is onpremise S/4HANA 2023.
We noticed that the update to the database takes over 2 minutes. We traced the db access. RAP utilizes the class CL_CSP_SQL_ACCESS to write the data to the database. The UPDATE statement uses the addition INDICATORS SET STRUCTURE %control.
The generated SQL statement send to the database looks like this:
UPDATE "DBTAB"
SET
"COLUMN1" = CASE ? WHEN 1 THEN ? ELSE "COLUMN1" END,
"COLUMN2" = CASE ? WHEN 1 THEN ? ELSE "COLUMN2" END,
...
WHERE "CLIENT" ...The whole statement is divided into smaller packages. The execution time is around 160 seconds for all packages.
As a workaround we set our entity to with unmanaged save with full data. Then we implemented the UPDATE ourself in the save_modified method:
IF update-entity IS NO INITIAL.
UPDATE dbtab FROM TABLE @update-entity MAPPING FROM ENTITY.
ENDIF.The execution time is now around 1 second for the whole UPDATE statement. The with full data addition costs another 1-2 seconds for reading the missing data.
We also tried unmanaged save without with full data and with added INDICATORS SET STRUCTURE %control which confirmed the poor performance of managed save.
There is another topic to this performance issue and a blog post about the INDICATORS SET STRUCTURE, but both are closed:
@ SAP: Are there any plans to improve performance of INDICATORS SET STRUCTURE or the managed database access?
@ community: has anybody noticed the same behaviour or any suggestions how to avoid this?
best regards
Christian