Skip to content

Slow import to MySQL

Chris Perivolaropoulos edited this page May 4, 2014 · 2 revisions

MySQL is a cruel mistress and one I have learned to avoid when it comes to migration. Thus to an experienced eye this may seem obvious but it was not to me.

First of all loading in parallel by blindly telling make to fork into n threads proves to silently fail to load most of the pages. Also the bottleneck is disk I/O rather than CPU so no point to it anyway.

A pretty good speedup came from wrapping each dump with

SET AUTOCOMMIT = 0; SET FOREIGN_KEY_CHECKS=0;
[...]
SET FOREIGN_KEY_CHECKS = 1;COMMIT; SET AUTOCOMMIT = 1;

See the corresponding code

Clone this wiki locally