Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Association on multiple tables in CDS Views

rashmi_11
Explorer
0 Kudos
7,976

Hello Experts,

I am kind of new to ABAP CDS views and want to join 4 tables. I read a number of performance optimization blogs and realised that it is not appropriate (performance wise) to join 4 tables. But I wanted to know if we can apply association between those 4 tables. Will it be better than join on 4 tables? Or should I go with associations in one single CDS View? Or I should layer the CDS Views? Any help would be appreciated.

Thanks in advance,
Rashmi

1 ACCEPTED SOLUTION

maheshpalavalli
Active Contributor
2,502

Hi Rashmi Khemani,

If the associations are created and used inside the cds view ( meaning: if you are exposing one of the field of the association in the cds view like below:)


maintablefield1,
maintablefield2,
association1.field1,

then it will behave same as the joins only.

If you are not using the association fields inside the cds view then the join will not be applied. Now the question, why we need association then? other uses cases like it will be used by odata service to generate the assocations and child entities or used by BOPF etc.,.

If you think it is reasonable to use join then use it. If your system is on hana then go a head with no worries. But don't expose all the unnecessary fields which will cause performance issue.

BR,

Mahesh

3 REPLIES 3

2,502

Dear Rashmi,

Would you mind find below best practices to following on ABAP CDS development.

https://www.sap.com/documents/2019/01/0e6d5904-367d-0010-87a3-c30de2ffd8ff.html

maheshpalavalli
Active Contributor
2,503

Hi Rashmi Khemani,

If the associations are created and used inside the cds view ( meaning: if you are exposing one of the field of the association in the cds view like below:)


maintablefield1,
maintablefield2,
association1.field1,

then it will behave same as the joins only.

If you are not using the association fields inside the cds view then the join will not be applied. Now the question, why we need association then? other uses cases like it will be used by odata service to generate the assocations and child entities or used by BOPF etc.,.

If you think it is reasonable to use join then use it. If your system is on hana then go a head with no worries. But don't expose all the unnecessary fields which will cause performance issue.

BR,

Mahesh

0 Kudos
2,502

Hi Rashmi,

As per my experience on CDS views there wont be any performance issue if you join 4 tables,In my project we have used more than 20 tables in single CDS view. The performance issue arises of you have huge volumes of data in your base tables which you are referring. Below are few practices you can follow while designing the CDS view.

1) Always try to limit the data from base tables using input parameters(Ex: We have ACDOCA table and volumes are huge, So try to restrict data for a particular year/quarter/period using input parameters)

2) Always try to use Association when ever you need master data. Performance wise they give better results since the join condition is executed only on demand i.e the join runs only when the filed is requested in the output

3) Filter the data from the base tables using where condition to limit the data

4) You can go with multiple layers if the logic is too complex(EX: You need to create multiple table functions to achieve business requirement and call those table functions in your CDS view)