CRM-20594: Optimze Counting of Reltionships on Contact Summary
Contacts with a lot of relationships (over 5000) were taking a lot of time to
load. This was because the count of relationships was being done by fetching
ALL records of relationships associated to the contact, and then counting the
number of elements in the resulting array.
Fixed by changing the call to CRM_Contact_BAO_Relationship::getRelationship()
being used in CRM_Contact_BAO_Contact::getCountComponent(), passing the
$count parameter as 1 instead of 0, so counting is done by the database by
building a 'SELECT COUNT(*)' type of query.
Also, removed some unnecessary joins when counting records in DB, ie. when
$count flag is 1.