Skip to Content
Technical Articles
Author's profile photo Abhimanyu Sharma

CDS view performance Annotation for CDS view performance

Just want to share few interesting points on the CDS view performance Annotation for CDS view performance. SAP has released some guidelines to improve the performance of CDS views.

The best way to learn these guidelines is to learn from standard CDS views and apply in our custom views.

 

In most of the standard CDS views, we have seen below 3 annotations being used by SAP in order to improve performance. But I have seen we are not using it in our custom views which might impact performance while fetching data. Hence it would be good practice to use these annotations properly and benefit with performance.

 

  1. @ObjectModel.usageType.serviceQuality
  2. @ObjectModel.usageType.sizeCategory
  3. @ObjectModel.usageType.dataClass

 

( Note : In case where we want to see list of CDS view doesn’t have these annotations,  SAP has provided a standard table : DDHEADANNO. This table will have information of all the annotations being used in CDS views present in the system. So you can create a report program on this table where we can find out CDS views which doesn’t have above annotations with %usagetype% keyword. )

 

Valid values for serviceQuality: #A, #B, #C, #D, #X, #P

 

Valid values for sizeCategory: #S, #M, #L, #XL, #XXL

 

Valid values for dataClass: #TRANSACTIONAL, #MASTER, #ORGANIZATIONAL, #CUSTOMIZING, #META, #MIXED

 

Now will see below charts where we will see in what cases we should use these annotations :  

 

 

 

 

Combination of Characteristics to be used for annotations in CDS views

 

Test Results :

 

 

Conclusion :

 

  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

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo ASHOK KUMAR
      ASHOK KUMAR

      Excellent article, keep up the good work!!

      Author's profile photo Abhilash Pradhan
      Abhilash Pradhan

      Excellent blog , helped me understand the concepts of these 3 .

      Author's profile photo Heiko Gerwens
      Heiko Gerwens

      No doubts that these annotations are useful also during custom development. They are meant to describe some characteristics of the CDS view with respect to their performance behavior in CDS queries. However, they should not have any impact on CDS query performance, because annotations are not even "known" by HANA. In your example you have probably observed another effect unrelated to these annotations. Would be great if you can share some more details of your example to figure out the root cause of the observed performance differences.

      Author's profile photo Yadhunand Srinivasan
      Yadhunand Srinivasan

      Hello Heiko Gerwens, Great point regarding the annotations. Is there any other documentation for the real value on these "Performance related annotations" other than for user information/readability/governance of CDS Objects ?

      Author's profile photo Andrea Schlotthauer
      Andrea Schlotthauer

      The ABAP Keyword Documentation describes these annotations under https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abencds_view_entity_anno.htm#@@ITOC@@ABENCDS_VIEW_ENTITY_ANNO_5.

      It says among others: "With the above subannotations of ObjectModel it can be documented for a view for which kind of application it is intended and which kind of data are to expected. This information is especially important in regards of performance that can be expected by the consumer of the view."

       

      Author's profile photo Heiko Gerwens
      Heiko Gerwens

      Those Annotations are e.g., used in ATC checks to insure that CDS views are only used in appropriate contexts

      Author's profile photo Udita Saklani
      Udita Saklani

      Hi Abhimanyu ,

       

      If in a  CDS I added an annotation that you have specified above, I observed an increased and better performance. But when I removed the annotation and ran the performance trace again, then the trace still shows improved performance.

      Any idea why it could be happening ?

      Thanks & Regards,

      Udita Saklani

      Author's profile photo Andreas Riehl
      Andreas Riehl

      Hi Udita,

      As Heiko stated above (December 2020), setting the annotations @ObjectModel.usageType.dataClass, -serviceQuality or -sizeCategory has no impact on the actual performance at all. The performance improvements you observed when setting them are related to other reasons. This also explains why removing them had no negative impact on the performance.

      Best Regards,
      Andreas

      Author's profile photo Udita Saklani
      Udita Saklani

      ThanksAndreas Riehl,

      For the response.
      But my question still remains valid,
      How did the performance increase drastically after I added the annotations( I mean what could be the other reasons like you just stated)?

       

      Thanks ,

      Udita Saklani

      Author's profile photo Andreas Riehl
      Andreas Riehl

      Hi Udita,

      I am not a performance expert, but the improvement is almost certainly not related to the annotations you set but a different effect. Which one is really hard to say without knowing the view and the way you tested the performance. Maybe just the data volume that had to be processed changed or the system had more free resources when you tested? Did you do repeated tests?

      Best Regards,
      Andreas

      Author's profile photo Balaji S
      Balaji S

      Hi,

      Maybe the records were buffered?

      Best Regards,

      Balaji