Archive for the ‘mysql tablespace drop table’ Category

A quicker drop table within MySQL

Апрель 27th, 2011
A drop table can be a timely locking operation though if a few preconditions are met we can reduce the locking time on the server and intern any performance consequence.

Whilst a truncate table operation is underway a lock mutex around the table is created to ensure data consistency; if using innodb file per table the physical .ibd file must be removed which is a painfully slow operation under ext3.

However to speed this up a quick solution is to hardlink the tablespace file somewhere else. This will make the removal of the file that MySQL performs a unlinking operation and not an operation involving foreground random IO.

Eg

host01:/databases/data/test# ln Session.ibd Session.ibd-remove
hostt01:/databases/data/test# mysql test

mysql> drop table Session;
Query OK, 0 rows affected (0.07 sec)

Then at some point where there are spare IO cycles

host01:/databases/data/test# rm Session.ibd-remove
host01:/databases/data/test#




PlanetMySQL Voting: Vote UP / Vote DOWN