ERPClimb logoERPClimb
CDS Views
RAP / CDS / ODataintermediate 10 min read

CDS Views Part 3: Performance — Joins, Associations, Filters and Aggregation

Preview · a free account unlocks the full lesson

Key takeaway

Make CDS views fast: understand how associations and path expressions turn into joins, why to-many paths multiply rows, how to push filters and aggregation to the database, and how to analyze a slow view.

In this lessonShow sections

Visual overview

CDS Views Part 3: Performance — Joins, Associations, Filters and Aggregation — learning sheetIn one line: Make CDS views fast: understand how associations and path expressions turn into joins, why to-many paths multiply rows, how to push filters and aggregation to the database, and how to analyze a slow view.ERPClimb.com / RAP / LESSON 3/4 / LEARNING SHEETCDS Views Part 3: Performance — Joins, Associations,Filters and Aggregation1 · IN ONE LINEMake CDS views fast: understand how associations and path expressions turn into joins, whyto-many paths multiply rows, how to push filters and aggregation to the database, and how toanalyze a slow view.2 · KEY IDEAS EXPLAINEDJoin vs AssociationA JOIN in the data source ("as select fromzso_head inner join zso_item on ...") isalways executed, even if the consumer never reads…An ASSOCIATION is only a declared relationship. Itbecomes a join only when a consumer actually usesit — via a path expression in a SELECT, in another…Path Expressions And What They GenerateTo-one associations ([0..1], [1..1]) are safe inthe select list: one row stays one row.To-many associations ([0..*], [1..*]) in theselect list or in WHERE multiply rows: an orderwith 5 items suddenly appears 5 times. This…Push Filters DownPut selective conditions into the WHERE of theconsumer's SELECT (or the consumption view), notin ABAP after the read.Avoid functions on filtered columns in join orWHERE conditions (e.g. comparing "substring(field, 1, 4 )"), because indexes and pruning…Aggregate In CDSSumming, counting and grouping belong in CDS withGROUP BY, not in ABAP loops. A view with"sum( NetAmount ) group by Customer…3 · DO · AVOIDBest practice!Common mistakeModel relationships as associations; letconsumers decide what to join.Use to-one paths or filtered paths in elementlists; keep to-many data for $expand or…Aggregate in CDS with GROUP BY, alwaysincluding currency or unit.✕Using hard joins in basic views "just incase" instead of associations.✕Placing to-many path expressions in the selectlist or WHERE, multiplying rows.✕Declaring wrong cardinality (e.g. [0..1] for arelation that is really to-many).4 · IN A REAL PROJECTA Fiori list of open sales orders took 40 seconds and showed some orders several times. The consumption viewcontained "_Item.Material" and "_Item.NetAmount" in its element list to show "amaterial" and "an amount" per order. Both were to-many paths: each order was returned once per…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 2 built ZI_SalesOrderItem. Now comes the question every project hits after go-live: why is this CDS-based list slow, and how do you design views that stay fast with millions of rows?

The core idea is that a CDS view is executed as SQL on SAP HANA, so performance depends on how much data the database has to read, join and send back. Good design means filtering early, joining only what's needed, aggregating in the database, and returning only the columns and rows the consumer actually needs.

The distinction between a join and an association matters a great deal. A JOIN in the data source — "as select from zso_head inner join zso_item on ..." — always executes, even if the consumer never reads a joined field.

An ASSOCIATION, by contrast, is only a declared relationship, and it becomes a join only when a consumer actually uses it, whether through a path expression in a SELECT, in another view, or via OData $expand.

So it pays to model relationships as associations and let consumers decide — a list report that shows only the order number and date never pays for the customer join.

Path expressions are what turn an association into an actual join. "_Customer.CustomerName" in a view's element list, or "\_Customer-CustomerName" in ABAP SQL, generates a LEFT OUTER JOIN by default to the associated view. To-one associations ([0..1], [1..1]) are safe to use in a select list, since one row stays one row.

To-many associations ([0..*], [1..*]), though, multiply rows when used in a select list or in a WHERE clause — an order with 5 items suddenly appears 5 times, producing wrong counts and slow queries.

A to-many path can be turned into a to-one path with a filter, such as "_Item[ ItemNumber = '000010' ].Material", or with a "1:" cardinality hint when the filter guarantees a single row. Cardinality should always be declared correctly, since getting it wrong lets the optimizer choose bad plans and hides duplicates.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.