Topic : The blog will discuss on the Topic of Performance optimization for CDS views.
As an ABAP CDS view developer working in S/4HANA projects, Please find the points we need to check while developing the view.
General Architecture for SAP S/4HANA:
SQL Processing Steps :
CDS Views Complexities :
1.CDS views stacking can get so complex that it results in performance degradation
2.Number of execution plan variants raises according (#??????)?HANA optimizer could fail to find the optimal execution plan.
3.By using layered CDS views, formerly fast accesses to buffered tables and application caches on ABAP server might be replaced by complex database accesses
4.Declarative programming style of SQL can have a performance drawback since optimizer plans do not take into account the actual attributes of a statement. Cutting away unnecessary execution branches might not be done with the same efficiency as with imperative programming in ABAP
Display Complexity of the CDS views:
ADT ( ABAP Development Tools for Eclipse) > Open with Dependency Analyzer.
Note :
Separate transactional data, master data, org data, customizing, and other metadata This is important to leverage caches on the application server for meta data.
Classification of CDS views using performance annotations :
@ObjectModel.usageType.serviceQuality
quality of service with respect to the expected performance of the CDS view
@ObjectModel.usageType.dataClass
type of data in CDS view (transactional data, master data, …)
@ObjectModel.usageType.sizeCategory
set of data whichhas to be searched through in order to compute the result set
CDS views: performance annotations
service-Quality of CDS views: requirements and KPIs:
Generate SQL statement for CDS Views:
ADT ( ABAP Development Tools for Eclipse)> View SQL statement.
SQL Tips :
Exposed non NULL preserving calculated field
The blow example 2. Result 385% improvement of Query execution :
Example 1: The output time was 883 ms
Example 2: The output time was 34 ms
Limit push down and aggregation push down :
•Order by: first sort, then limit problem for calculated fields
•Distinct operator, any aggregation
•cardinality changing joins (e.g. LoJoin TO MANY)
Rounding (and other functions) stop optimizer from pushing down aggregations
Currency conversion and all arithmetic operations except +/-contain implicit rounding functions
Special Note on Performance Recommendation:-
1. Keep CDS views simple (in particular service-Quality A and B = #BASIC views)
2. Amount of data persisted in S4 CDS views should not exceed 20% of the overall data volume of the system.
3. In transactional processing, only use simple CDS views accessed via CDS key
4. Expose only required fields –define associations to reach additional fields when requested
5. Perform expensive operations (e.g. calculated fields) after data reduction (filtering, aggregation)
6. Avoid joins and filters on calculated fields
7. Test performance of CDS views. Test with reasonable (= realistic) test data
8. Analyze accesses to more complex views with HANA PlanViz to see whether filters are pushed down to all brances.
9. Stay tuned on caching possibilities of SAP HANA and Fiori apps
Ref:-SAH300