fixes CRM-14175, ignore bulk activities while fetching contact names for activities
authorkurund <kurund@civicrm.org>
Thu, 6 Feb 2014 00:40:52 +0000 (16:40 -0800)
committerkurund <kurund@civicrm.org>
Thu, 6 Feb 2014 00:40:52 +0000 (16:40 -0800)
----------------------------------------
* CRM-14175: activity tab on contact summary is super slow
  http://issues.civicrm.org/jira/browse/CRM-14175

CRM/Activity/BAO/Activity.php

index 938c8d8eba02a0f41e6e02032d4f300df0c35503..8cb0c29c5951a9ee84f1c55e658189eef4e2b5d2 100644 (file)
@@ -760,7 +760,8 @@ LEFT JOIN  civicrm_case_activity ON ( civicrm_case_activity.activity_id = tbl.ac
     // create temp table for target contacts
     $activityContactTempTable = "civicrm_temp_activity_contact_{$randomNum}";
     $query = "CREATE TEMPORARY TABLE {$activityContactTempTable} (
-                activity_id int unsigned, contact_id int unsigned, record_type_id varchar(16), contact_name varchar(255), is_deleted int unsigned )
+                activity_id int unsigned, contact_id int unsigned, record_type_id varchar(16),
+                 contact_name varchar(255), is_deleted int unsigned, INDEX index_activity_id( activity_id ) )
                 ENGINE=MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
 
     CRM_Core_DAO::executeQuery($query);
@@ -773,8 +774,9 @@ SELECT     ac.activity_id,
            ac.record_type_id,
            c.sort_name,
            c.is_deleted
-FROM       civicrm_activity_contact ac
-INNER JOIN {$activityTempTable} ON ( ac.activity_id = {$activityTempTable}.activity_id )
+FROM       {$activityTempTable}
+INNER JOIN civicrm_activity a ON ( a.id = {$activityTempTable}.activity_id AND a.activity_type_id != {$bulkActivityTypeID} )
+INNER JOIN civicrm_activity_contact ac ON ( ac.activity_id = {$activityTempTable}.activity_id )
 INNER JOIN civicrm_contact c ON c.id = ac.contact_id
 ";
     CRM_Core_DAO::executeQuery($query);