CDS Views Part 10: Performance and Troubleshooting
Lessons are open to try during our launch period. Some advanced content may move to Pro later. AI practice limits apply separately.
Keep CDS pushdown fast: understand how view stacks become one SQL statement, avoid expensive patterns (functions in joins, to-many paths, early currency conversion, deep stacks, unused joins), and analyse slow views with the SQL CREATE statement, ST05, SQL Monitor, the ADT dependency analyzer and HANA PlanViz.
In this lessonShow sectionsHide sections
Visual overview
Expert visual walkthrough
Performance and Troubleshooting
CDS Views · Chapter-specific technical teaching map
Integration path
Reproduce symptoms
Check metadata / logs
Inspect backend
Correct and retest
Tutor's chapter takeaway
Keep CDS pushdown fast: understand how view stacks become one SQL statement, avoid expensive patterns (functions in joins, to-many paths, early currency conversion, deep stacks, unused joins), and analyse slow views with the SQL CREATE statement, ST05, SQL Monitor, the…
In a real project
A group-currency sales dashboard took 90 seconds to open. ST05 showed one statement reading 30 million VBAK/VBAP rows; PlanViz showed currency conversion running on every row before the filter on sales organization was…
Watch out for
• Assuming "it's CDS, so it's fast" without measuring. • Currency conversion on every row before filtering or aggregation. • Consumers filtering on calculated fields instead of base columns. • Functions or casts in join…
The situation: a real project scenario
A group-currency sales dashboard took 90 seconds to open. ST05 showed one statement reading 30 million VBAK/VBAP rows; PlanViz showed currency conversion running on every row before the filter on sales organization was applied, because the filter field was a CASE-derived value.
The team exposed sales organization as a plain column so the filter reached the base table, aggregated per currency before conversion, and removed two joins that no consumer used. The dashboard opened in 3 seconds, with totals reconciled against the old version.
Explanation
Parts 1 through 9 built a full CDS model; this final part is about keeping it fast in production. A CDS view stack compiles into a single SQL statement — the consumer's SELECT plus every view beneath it — and HANA optimizes that whole statement, but only what it can actually see and simplify.
Unused associations aren't joined at all (join on demand), but joins written directly into a view's definition stay part of the statement unless HANA can prove they're removable, which requires correct cardinality and no usage of the joined fields.
Pushdown is not automatically fast: moving a bad algorithm into the database still leaves you with a bad algorithm, just a harder one to debug.
Most slow CDS views trace back to a handful of recurring patterns: functions or casts inside ON conditions (such as concat or a cast on key fields), which prevent index use; to-many paths pulled into the field list, which explode rows before any aggregation happens on top; currency_conversion or unit_conversion applied to millions of rows before filtering; CASE expressions or other calculated fields used in a consumer's WHERE clause, which can't be pushed down to the base table's index; deep stacks of ten or more levels with repeated joins to the same table; and UNION views where one branch reads a huge table with no filters at all.
A few design rules follow from this. Filter early, keeping selective fields available as plain columns so a consumer's WHERE clause can actually reach the base table. Aggregate before converting currency or units wherever the business allows it, converting only the reduced result set. Join on key fields with matching types, and declare cardinality honestly. Keep consumption views thin, and avoid building consumption views on top of other consumption views. And in consumers, select only the fields you actually need, since fields from unused joins may then get pruned.
A set of tools support this analysis. In ADT, opening a view and choosing "Show SQL CREATE Statement" reveals the generated SQL, while the Dependency Analyzer shows the full view stack along with join count and complexity. ST05 gives you an SQL trace of the consumer, including duration and records per statement, plus an Explain function for the execution plan.
SQL Monitor (SQLM) shows which statements cost the most in production over time, and HANA PlanViz gives an operator-level plan showing exactly where rows explode or where filters get applied too late.
A practical troubleshooting workflow follows these tools in sequence: reproduce the problem with the exact consumer SELECT and data volume, trace it with ST05 and note duration and row counts, check the stack in the Dependency Analyzer, look for the patterns described above and test by removing one join or calculation at a time, then re-measure and compare row counts and totals after each change.
To put this into practice: take a slow custom view and open its Dependency Analyzer, run the consumer with ST05 active and record the runtime, move a currency conversion to after aggregation or replace a function-based join with a key join, then re-trace and compare. By the end you should be able to find and fix the typical causes of slow CDS views using measurements rather than guesses.
Code example
// ===== STEP 1: SLOW - convert every row, then consumers filter/aggregate =====@AccessControl.authorizationCheck: #NOT_REQUIRED@EndUserText.label: 'Slow: conversion on all rows'define view entity ZI_SalesEurSlow as select from vbak{ key vbeln as SalesOrder, kunnr as SoldToParty, erdat as CreationDate, @Semantics.amount.currencyCode: 'TargetCurrency' currency_conversion( amount => netwr, source_currency => waerk, target_currency => cast( 'EUR' as abap.cuky ), exchange_rate_date => erdat, error_handling => 'SET_TO_NULL' ) as NetAmountEur, cast( 'EUR' as abap.cuky ) as TargetCurrency} // ===== STEP 2: FASTER - aggregate per currency first (Part 3 view), =====// ===== then convert only the few aggregated rows =====@AccessControl.authorizationCheck: #NOT_REQUIRED@EndUserText.label: 'Faster: convert after aggregation'define view entity ZI_SalesEurFast as select from ZI_SalesByCustomer{ key SoldToParty, key TransactionCurrency, @Semantics.amount.currencyCode: 'TargetCurrency' currency_conversion( amount => TotalNetAmount, source_currency => TransactionCurrency, target_currency => cast( 'EUR' as abap.cuky ), exchange_rate_date => $session.system_date, error_handling => 'SET_TO_NULL' ) as TotalNetAmountEur, cast( 'EUR' as abap.cuky ) as TargetCurrency}// Note: rate date changes from order date to today - confirm with business. * ===== STEP 3: classic consumer - select only needed fields =====REPORT zcds_perf_check. DATA: lv_t0 TYPE i, lv_t1 TYPE i, lv_ms TYPE i, lv_lines TYPE i. TYPES: BEGIN OF ty_row, soldtoparty TYPE kunnr, totalnetamounteur TYPE netwr_ak, END OF ty_row.DATA lt_row TYPE STANDARD TABLE OF ty_row. START-OF-SELECTION.* ===== STEP 4: measure (run with ST05 for the SQL detail) ===== GET RUN TIME FIELD lv_t0. SELECT soldtoparty totalnetamounteur FROM zi_saleseurfast INTO TABLE lt_row. GET RUN TIME FIELD lv_t1. lv_ms = ( lv_t1 - lv_t0 ) / 1000. DESCRIBE TABLE lt_row LINES lv_lines. WRITE: / 'Rows:', lv_lines, / 'Runtime (ms):', lv_ms.Watch out
Common mistakes
- Assuming "it's CDS, so it's fast" without measuring.
- Currency conversion on every row before filtering or aggregation.
- Consumers filtering on calculated fields instead of base columns.
- Functions or casts in join conditions.
- Tuning without comparing row counts and totals afterwards.
Do this
Best practices
- Measure first: ST05, SQLM, PlanViz.
- Keep filter fields as plain columns; filter early.
- Aggregate before converting where the business rule allows.
- Review stacks with the Dependency Analyzer; remove unused joins.
- After every tuning change, verify results against the original.
In the interview
Interview angle
Questions: "A CDS-based Fiori app is slow — how do you analyse it?", "Which CDS patterns hurt performance?", "Does pushdown always improve performance?"
Strong answer: reproduce, trace with ST05, check the stack in the Dependency Analyzer and the generated SQL, use PlanViz for the plan and SQLM for production hotspots. Typical causes: functions in joins, to-many paths, conversions on all rows, filters on calculated fields, deep stacks and unused joins. Pushdown helps only when the logic is set-based and filters early; a bad design in the database stays slow.
Practice this lesson
Quick check
0 of 3 questions attempted
Question 1 of 3
A dashboard view applies currency_conversion to every order row, then consumers filter by sales org and aggregate. What is the best improvement?
Question 2 of 3
Consumers of a large CDS view filter on a field computed with CASE. Why can this be slow?
Question 3 of 3
Which CDS artifact allows embedding complex ABAP logic (via an AMDP method) that cannot be expressed in standard CDS view syntax, while still exposing the result as a queryable, strongly-typed data source?
Practise this in an interview
Answer in your own words and get instant feedback, the way an interviewer would judge it.
1A CDS view is slow in production. How would you analyze and improve it?
2A Fiori consumption view exposes many associations and path fields and takes 90 seconds to load. How do you analyse and speed it up?
Try a related Code Lab
This published exercise covers the same SAP topic. Apply the ideas in a hands-on scenario, then return to review your answers.
Open: Slow CDS View Due to Too Many Joins and No Filters →Was this lesson helpful?
Keep exploring
Interview questions on this topic
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.