patternsqlMajor
slow load speed of data from mysqldump
Viewed 0 times
mysqldumpslowloadfromdataspeed
Problem
I've got a moderate size MySQL database with about 30 tables, some of which are 10 million records, some 100 million. The
When I load the data into MySQL on another box, a six-core, 8GB machine, it takes forever. Easily 12 clock hours or more.
I'm just running the mysql client to load the file, i.e.
directly with the file directly out of mysqldump
Clearly I am doing something wrong. Where do I start so it can finish in a reasonable time?
I'm not using any switches on either the dump or the load.
mysqldump of all the tables (into separate files) is fairly fast, takes maybe 20 minutes. It generates about 15GB of data. The largest dumped files are in the 2GB range.When I load the data into MySQL on another box, a six-core, 8GB machine, it takes forever. Easily 12 clock hours or more.
I'm just running the mysql client to load the file, i.e.
mysql database < footable.sqldirectly with the file directly out of mysqldump
mysqldump database foo > footable.sqlClearly I am doing something wrong. Where do I start so it can finish in a reasonable time?
I'm not using any switches on either the dump or the load.
Solution
Take these some points in your consideration they may help you in case of generating the dump and restoring it.
Give it a try..
- Use
Extended insertsin dumps.
- Dump with
--tabformat so you can usemysqlimport, which is faster thanmysql
- Import with multiple threads, one for each table.
- Use a different database engine if possible. importing into a heavily transactional engine like innodb is awfully slow. Inserting into a non-transactional engine like MyISAM is much much faster.
- Turn off foreign key checks and turn on auto-commit.
- If you are importing to innodb the single most effective thing you can do is to put innodb_flush_log_at_trx_commit = 2` in your my.cnf, temporarily while the import is running. you can put it back to 1 if you need ACID
Give it a try..
Context
StackExchange Database Administrators Q#13446, answer score: 25
Revisions (0)
No revisions yet.