Issue with Return Value For Target Contacts Parameter in Activity Get API
When calling the Activity.Get API and part of the fields to be returned is the
target_contact_id, the values for this field can grow really huge especially for the Bulk Email activity type. The value could sometimes run into thousands and this could affect performance for an Application that needs to have this parameter returned.
$result = civicrm_api3('Activity', 'get', [ 'sequential' => 1, 'return' => ["target_contact_id"], ]);
When checking the default Core Activity page (
civicrm/contact/view/activity) , I looked into how Core handles the Target contacts field on this page, It turns out that the fetch for the Target contact is limited to one per activity (See Here) so that is why there is no performance issue on that page.
I think that both the API and the Backend implementation should be aligned or at least allow the API to specify the number of target contacts to be returned for an Activity otherwise this becomes a huge performance issue for Frontends that need this API to create a view similar to
civicrm/contact/view/activity and making use of the API.