Rule Definition
If the cardinality is specified, any databases that support this addition assume that the results set defined by association matches this cardinality and SQL Optimizer attempts to suppress any surplus joins.
Remediation
Set cardinality to associations.
Violation Code Sample
define view demo_cds_wrong_cardinality
as select from
scarr
association to spfli as _spfli on
_spfli.carrid = scarr.carrid
{
scarr.carrid as carrid,
scarr.carrname as carrname,
_spfli.connid as connid
}
Fixed Code Sample
define view demo_cds_explicit_cardinality
as select from
scarr
association [1..*] to spfli as _spfli on
_spfli.carrid = scarr.carrid
{
scarr.carrid as carrid,
scarr.carrname as carrname,
_spfli.connid as connid
}
Reference
https://blogs.sap.com/2018/12/20/safeguard-performance-of-abap-cds-views-part-3-rules-for-good-performance-of-cds-views/
https://blogs.sap.com/2018/08/20/cardinality-of-association-in-cds-view/
Related Technologies
Technical Criterion
Efficiency - SQL and Data Handling Performance
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.