简体   繁体   中英

Need Help regarding Mysql Truncate table

I have a 150 gb MYSQL table(innodb) which is not currently using. I am sort of disk so I need to truncate the table and reclaim the space. innodb_file_per_tble is on. Table truncation is in process from last one hour but still not truncated. There are no foreign key checks only 3 or 4 indexes. After checking the show processlist it's showing state updating. Need some tips and help what is the best possible way(truncate/drop). What's mysql tried to do internally? Table size 150gb.space left at machine-35gb. Your help will be truly appreciated.

For an InnoDB table before version 5.0.3, InnoDB processes TRUNCATE TABLE by deleting rows one by one. As of MySQL 5.0.3, row by row deletion is used only if there are any FOREIGN KEY constraints that reference the table. If there are no FOREIGN KEY constraints, InnoDB performs fast truncation by dropping the original table and creating an empty one with the same definition, which is much faster than deleting rows one by one. (When fast truncation is used, it resets any AUTO_INCREMENT counter to zero. From MySQL 5.0.13 on, the AUTO_INCREMENT counter is reset to zero by TRUNCATE TABLE, regardless of whether there is a foreign key constraint.)

Check this out: http://dev.mysql.com/doc/refman/5.0/en/truncate-table.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM