Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-10700

TRUNCATE is slow on some versions of Mysql InnoDB

    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.

        Attachments

        1. CRM-10700_v2.patch
          3 kB
          Adam Wight
        2. delete_from.patch
          4 kB
          Adam Wight

          Activity

            People

            • Assignee:
              pratik.joshi Pratik Joshi
              Reporter:
              adamw Adam Wight
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: