Skip to content

Commit

Permalink
wmf: CRM-10700 use DELETE FROM instead of TRUNCATE
Browse files Browse the repository at this point in the history
The performance of TRUNCATE is slower than DELETE FROM.

Probably due to

Note that this provides a way to stop hacking core
civicrm/civicrm-packages#180
  • Loading branch information
eileenmcnaughton committed Aug 26, 2019
1 parent b0cd861 commit 9bd28b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CRM/ACL/BAO/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
12 changes: 6 additions & 6 deletions CRM/Core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];

Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9bd28b2

Please sign in to comment.