From: Allen Shaw Date: Tue, 28 Aug 2018 16:55:43 +0000 (-0500) Subject: dev/core#367: Query optimization for A-Z pager by adding indices to temp table. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=08fa90dcf72f744de6990a761449b48497ba9876;p=civicrm-core.git dev/core#367: Query optimization for A-Z pager by adding indices to temp table. --- diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 57643ede26..2b0b209fd2 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -4208,6 +4208,12 @@ civicrm_relationship.start_date > {$today} } $sql = " CREATE TEMPORARY TABLE {$relationshipTempTable} + ( + `contact_id` int(10) unsigned NOT NULL DEFAULT '0', + `contact_id_alt` int(10) unsigned NOT NULL DEFAULT '0', + KEY `contact_id` (`contact_id`), + KEY `contact_id_alt` (`contact_id_alt`) + ) (SELECT contact_id_b as contact_id, contact_id_a as contact_id_alt, civicrm_relationship.id FROM civicrm_relationship INNER JOIN civicrm_contact c ON civicrm_relationship.contact_id_a = c.id