Details
-
Type: Patch
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Won't Fix
-
Affects Version/s: 4.1.1, 4.2.0
-
Fix Version/s: Unscheduled
-
Component/s: Core CiviCRM
-
Labels:
-
Documentation Required?:None
-
Funding Source:Needs Funding
Description
There has been a long-standing bug in InnoDB which causes TRUNCATE to be much slower than DELETE FROM, or even DROP / CREATE. I noticed the problem while running the "devel" module query profiling. Truncates can take 20-200ms, on an empty table, while a delete is < 1ms.
This bug was reported in Mysql 4.1, http://bugs.mysql.com/bug.php?id=7150, and still affects Mysql 5.5.24
Correction: Current behavior is explained here: http://dev.mysql.com/doc/refman/5.6/en/innodb-other-changes-truncate.html
The attached patch replaces instances of "TRUNCATE" in core code.
Incidentally, the worst offender here was CRM_ACL_BAO_Cache, which insists on truncating an empty table at every opportunity.