Ejegg has submitted this change and it was merged.
Change subject: Chop out wildcard usages of civicrm_prevnext_cache
......................................................................
Chop out wildcard usages of civicrm_prevnext_cache
Sort of brute force approach. These queries were really expensive, and
for no reason. I'd like to just match the damn key, but will conservatively
only rewrite infix searches as prefix searches.
Change-Id: I11aaedc570b6ba6cfa173c3ac07e83059a58904e
---
M CRM/Contact/Selector.php
M CRM/Core/BAO/PrevNextCache.php
2 files changed, 9 insertions(+), 9 deletions(-)
Approvals:
Ejegg: Looks good to me, approved
diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php
index f998ee9..9dd2098 100644
--- a/CRM/Contact/Selector.php
+++ b/CRM/Contact/Selector.php
@@ -799,7 +799,7 @@
$sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter',
'String', CRM_Core_DAO::$_nullObject);
//for text field pagination selection save
- $countRow = CRM_Core_BAO_PrevNextCache::getCount("%civicrm search
{$cacheKey}%", NULL, "entity_table = 'civicrm_contact'", "LIKE");
+ $countRow = CRM_Core_BAO_PrevNextCache::getCount("civicrm search
{$cacheKey}%", NULL, "entity_table = 'civicrm_contact'", "LIKE");
if ((!$crmPID || $countRow == 0) && !$sortByCharacter) {
$this->fillupPrevNextCache($sort);
diff --git a/CRM/Core/BAO/PrevNextCache.php b/CRM/Core/BAO/PrevNextCache.php
index fd91000..d401c05 100644
--- a/CRM/Core/BAO/PrevNextCache.php
+++ b/CRM/Core/BAO/PrevNextCache.php
@@ -326,13 +326,13 @@
$whereClause .= "AND is_selected = 0";
$sql = "
UPDATE civicrm_prevnext_cache SET is_selected = 1 " . $whereClause .
$entity_whereClause;
- $params[1] = array("%{$cacheKey}%", 'String');
+ $params[1] = array("{$cacheKey}%", 'String');
}
elseif ($action == 'unselect') {
$whereClause .= "AND is_selected = 1";
$sql = "
UPDATE civicrm_prevnext_cache SET is_selected = 0 " . $whereClause .
$entity_whereClause;
- $params[1] = array("%{$cacheKey}%", 'String');
+ $params[1] = array("{$cacheKey}%", 'String');
}
// default action is reseting
}
@@ -341,7 +341,7 @@
UPDATE civicrm_prevnext_cache SET is_selected = 0
WHERE cacheKey LIKE %1 AND is_selected = 1
" . $entity_whereClause;
- $params[1] = array("%{$cacheKey}%", 'String');
+ $params[1] = array("{$cacheKey}%", 'String');
}
CRM_Core_DAO::executeQuery($sql, $params);
}
@@ -371,7 +371,7 @@
$entity_whereClause
ORDER BY id
";
- $params[1] = array("%{$cacheKey}%", 'String');
+ $params[1] = array("{$cacheKey}%", 'String');
$contactIds = array($cacheKey => array());
$cIdDao = CRM_Core_DAO::executeQuery($sql, $params);
@@ -392,8 +392,8 @@
FROM civicrm_prevnext_cache
WHERE cacheKey LIKE %1 AND is_selected=1 AND cacheKey NOT LIKE %2
LIMIT $offset, $rowCount";
- $params1[1] = array("%{$cacheKey}%", 'String');
- $params1[2] = array("%{$cacheKey}_alphabet%", 'String');
+ $params1[1] = array("{$cacheKey}%", 'String');
+ $params1[2] = array("{$cacheKey}_alphabet%", 'String');
$dao = CRM_Core_DAO::executeQuery($query, $params1);
while ($dao->fetch()) {
$val[] = $dao->data;
@@ -419,8 +419,8 @@
SELECT count(id)
FROM civicrm_prevnext_cache
WHERE cacheKey LIKE %1 AND is_selected=1 AND cacheKey NOT LIKE %2";
- $params1[1] = array("%{$cacheKey}%", 'String');
- $params1[2] = array("%{$cacheKey}_alphabet%", 'String');
+ $params1[1] = array("{$cacheKey}%", 'String');
+ $params1[2] = array("{$cacheKey}_alphabet%", 'String');
$paramsTotal = CRM_Core_DAO::singleValueQuery($query, $params1);
$params['total'] = $paramsTotal;
$obj->_pager = new CRM_Utils_Pager($params);
--
To view, visit https://gerrit.wikimedia.org/r/178569
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I11aaedc570b6ba6cfa173c3ac07e83059a58904e
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/fundraising/crm/civicrm
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits