From 9bd28b295250e768999d9460802cbc08424bcbc2 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Tue, 8 Sep 2015 13:10:01 +1200 Subject: [PATCH] wmf: CRM-10700 use DELETE FROM instead of TRUNCATE The performance of TRUNCATE is slower than DELETE FROM. Probably due to Note that this provides a way to stop hacking core https://github.com/civicrm/civicrm-packages/pull/180 --- CRM/ACL/BAO/Cache.php | 4 ++-- CRM/Core/Config.php | 12 ++++++------ CRM/Core/Menu.php | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CRM/ACL/BAO/Cache.php b/CRM/ACL/BAO/Cache.php index 921adfeaf6c0..0a2b0ad6a44a 100644 --- a/CRM/ACL/BAO/Cache.php +++ b/CRM/ACL/BAO/Cache.php @@ -166,11 +166,11 @@ public static function resetCache() { // CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); // Transaction-safe if (CRM_Core_Transaction::isActive()) { CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, function () { - CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); + CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); }); } else { - CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); + CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); } } diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index b9c632feb6d2..cc24b6895427 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -348,13 +348,13 @@ public function clearModuleList() { */ public static function clearDBCache() { $queries = [ - 'TRUNCATE TABLE civicrm_acl_cache', - 'TRUNCATE TABLE civicrm_acl_contact_cache', - 'TRUNCATE TABLE civicrm_cache', - 'TRUNCATE TABLE civicrm_prevnext_cache', + 'DELETE FROM civicrm_acl_cache', + 'DELETE FROM civicrm_acl_contact_cache', + 'DELETE FROM civicrm_cache', + 'DELETE FROM civicrm_prevnext_cache', 'UPDATE civicrm_group SET cache_date = NULL', - 'TRUNCATE TABLE civicrm_group_contact_cache', - 'TRUNCATE TABLE civicrm_menu', + 'DELETE FROM civicrm_group_contact_cache', + 'DELETE FROM civicrm_menu', 'UPDATE civicrm_setting SET value = NULL WHERE name="navigation" AND contact_id IS NOT NULL', ]; diff --git a/CRM/Core/Menu.php b/CRM/Core/Menu.php index 796491120402..fce5d7c3f568 100644 --- a/CRM/Core/Menu.php +++ b/CRM/Core/Menu.php @@ -300,7 +300,7 @@ public static function build(&$menu) { public static function store($truncate = TRUE) { // first clean up the db if ($truncate) { - $query = 'TRUNCATE civicrm_menu'; + $query = 'DELETE FROM civicrm_menu'; CRM_Core_DAO::executeQuery($query); } $menuArray = self::items($truncate);