Starting with the InnoDB storage engine, when the user requests to
TRUNCATE
a table that is stored in an .ibd file of its
own (because innodb_file_per_table was enabled when the table
was created), and if the table is not referenced in a
FOREIGN KEY constraint, the InnoDB storage engine will drop and
re-create the table in a new .idb file. This
operation is much faster than deleting the rows one by one, and
will return disk space to the operating system and reduce the size
of page-level backups.
Previous versions of InnoDB would re-use the existing
.idb file, thus releasing the space only to
InnoDB for storage management, but not to the operating system.
Note that when the table is truncated, the count of rows affected
by the TRUNCATE command is an arbitrary number.
Note: if there are referential constraints between the table being
truncated and other tables, MySQL instead automatically converts
the TRUNCATE command to a
DELETE command that operates row-by-row, so
that ON DELETE operations can occur on
“child” tables.
This is the User’s Guide for InnoDB storage engine 1.1 for MySQL 5.5, generated on 2010-04-13 (revision: 19994) .
