Slow Truncating InnoDB Tables that have Foreign Keys set on them
Aug 10, 2010 · 1 minute readCategory: mysql
This is post is now quite old and the the information it contains may be out of date or innacurate.
If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub
However, if you need to empty a large table, you will find that this process is really slow.
The solution is to first of all truncate all of the tables that have foreign key relations set on the main table and then only empty the main table once those child tables are emptied.
Yes this defeats the object a bit, but if you want speed, this is the solution. It is incredibly fast in comparison, and the end result is the same.