I plan to insert about 100 million rows into my simple db table where the first column is indexed varchar(256) (see below col1), to make insertion faster, I issued a disable keys statement prior to insert. so my process is like this:
alter table xxx disable keys;
insert ignore into xxx(col1, col2) values('a',1), values('b',1), values('c',1)...
alter table xxx enable keys;
I’m inserting 1 million at a time using the above statement(so about 1 million values pair).
The first 15 millions goes pretty fast and constant(within reasonable speed of 30 seconds per million),
however, now I started another process of insertion of about only 1 mil into xxx, it takes forever(an hour into it and still has not finished).
am I missing something? does anything need to be tuned?
You should try using the mysql LOAD DATA INFILE command instead of individual inserts. This is typically much faster. Check out the documentation:
http://dev.mysql.com/doc/refman/5.1/en/load-data.html
Also, if this is a table you’ll never update or delete data from, you could try converting the table to use the archive engine (instead of InnoDB or any others). This engine is made for storing massive amounts of records and is very fast to insert new records. Check this out for more:
http://dev.mysql.com/tech-resources/articles/storage-engine.html