04-12-2022 7:44 AM
Hi all,
today I stumbled across a question I could not find any answer to myself.
I created a new CDS View with JOINs and ASSOCIATIONS for my usecase. Just ignore the tables, they are CRMish:
define view ZCRM_PROD_IB_INSTALLED
as select from comm_product as prod
inner join ZCRM_CURRENT_DATE as ts
on prod.client = ts.mandt
inner join zcrmd_prod_idx as idx
on prod.product_guid = idx.product_guid
association [0..1] to ibin as comp
on idx.product_guid22 = comp.objnr
and comp.valfr <= ts.curr_ts
and comp.valto >= ts.curr_ts
.... many more associations
{
prod.product_id,
prod.product_guid,
idx.product_guid22,
comp.ibase,
comp.instance,
.... many more fields
}
In my application I define myself a SELECT COUNT in ABAP to get the number of entries fitting my query:
SELECT COUNT(*)
FROM ZCRM_PROD_IB_INS
WHERE product_id in @lrt_prod
INTO @lv_count.
As far as I understand ASSOCIATIONS in CDS they are only added to the query if any column from it is used in the SELECT (for instance in SELECT or WHERE).
How does this work with SELECT COUNT(*)? Are the ASSOCIATIONS always added or not?
Does anybody have any idea how this affects performance?
I am thankful for any pointers or opinions!
cheers Carsten