Using TRUNCATE TABLE
on an InnoDB table requires a full table lock because TRUNCATE TABLE is DDL (Data Definition Language) not DML (Data Manipulation).
Doing DELETE FROM user_engagements;
will not help because MVCC info is written to the undo logs in ibdata1, and that can hold up the table from being emptied. If any uncommitted transactions are holding onto user_engagements
, that could potentially hold up a TRUNCATE tableTRUNCATE TABLE
as well.
You could rename the table so that it is immediately available
SET FOREIGN_KEY_CHECKS = 0;
CREATE TABLE user_engagements_new LIKE user_engagements;
ALTER TABLE user_engagements RENAME user_engagements_zap;
ALTER TABLE user_engagements_new RENAME user_engagements;
DROP TABLE user_engagements_zap;
SET FOREIGN_KEY_CHECKS = 1;
This should replicate quickly except for the last statement.
Give it a Try !!!
If you have MySQL 5.1.16+, TRUNCATE TABLE
requires DROP privilege. My answer performs what TRUNCATE TABLE
now does.
If you have MySQL 5.1.15 and back, you need DELETE privilege, which my answer covers.