I promised to write this up for for the folks who attended the Boston MySQL September User Group meeting, so here’s performance question #1 that was asked:
How can a bulk insert be speeded up?
We discussed disabling keys with
ALTER TABLE tblname DISABLE KEYS;
loading the data
ALTER TABLE tblname ENABLE KEYS;
However, as a post by Frank Mash not too long ago and comments explain, this has no effect on InnoDB tables.
For InnoDB tables, you can load the data in primary key order, which makes the loading much faster. Basically, InnoDB stores the data in primary key order on disk. If there is no primary key specified, the internal engine makes one anyway, so you might as well specify one and take advantage of it.
As well, you can
SET UNIQUE CHECKS=0 before the load and
SET UNIQUE CHECK=1 after the load if there are unique constraints. The final suggestion is to
SET AUTOCOMMIT=0 before the load and
SET AUTOCOMMIT=1 after the load, again to speed things up.
Comments are closed.