From fd28b6a0d74a2242a3e07eec5bb2a089e514dd21 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 1 Mar 2016 09:01:33 +1300 Subject: [PATCH] CRM-18124 Add index to civicrm_contribution.total_amount. --- CRM/Upgrade/Incremental/php/FourSeven.php | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index f80bb444cf..ec6282f129 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -165,6 +165,15 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base $this->addTask('Add Index to civicrm_contribution.source', 'addIndexContributionSource'); } + /** + * Upgrade function. + * + * @param string $rev + */ + public function upgrade_4_7_3($rev) { + $this->addTask('Add Index to civicrm_contribution.total_amount', 'addIndexContributionAmount'); + } + /** * CRM-16354 * @@ -500,4 +509,21 @@ FROM `civicrm_dashboard_contact` WHERE 1 GROUP BY contact_id"; return TRUE; } + /** + * CRM-18124 Add index to civicrm_contribution.total_amount. + * + * Note that I made this a combined index with receive_date because the issue included + * both criteria and they seemed likely to be used in conjunction to me in other cases. + * + * @param \CRM_Queue_TaskContext $ctx + * + * @return bool + */ + public function addIndexContributionAmount(CRM_Queue_TaskContext $ctx) { + CRM_Core_BAO_SchemaHandler::createIndexes(array( + 'civicrm_contribution' => array(array('total_amount', 'receive_date')), + )); + return TRUE; + } + } -- 2.25.1