HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMajor

slow load speed of data from mysqldump

Submitted by: @import:stackexchange-dba··
0
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 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.sql


directly with the file directly out of mysqldump

mysqldump database foo > footable.sql


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.

Solution

Take these some points in your consideration they may help you in case of generating the dump and restoring it.

  • Use Extended inserts in dumps.



  • Dump with --tab format so you can use mysqlimport, which is faster than mysql



  • 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.