MySQL – Risks of Using ‘Single-Transaction’ and ‘Extended-Insert’ on mysqldump

importMySQLmysqldump

I'm new in db administration and I've looked for a faster import of a mysqldump.

I had a db with about 1.1 million rows and mostly InnoDB tables and wanted this to import on a managed server. Before I used the standard mysqldump command for dumping the db. At import I had a write speed of about 60.000 rows per hour which was extremly slow.

I searched for a way to speed thingsup and found a post here saying to use –single-transaction and –extended-insert on mysqldump. Now the dump is importing in under 30 seconds.

After a quick overview it seems that the data is correctly imported but I'm a little bit leery about the fast import.

Why is this soo fast after adding these two options?
Are there any disadvantages on using this options?

Thank you for your help.

Best Answer

this way is faster because

  • Server does not need to perform fsync() multiple times during data import. fsync is the operation of submitting data into disk
  • Extended insert enables sequential write to disk which means disk does not need to seek for a locations for every row.
  • If the table has Auto_Increment values, Server can spare adequate values for the batch insertion at once rather than once for every insertion.
  • The extended insert builds batch INSERT statements (many rows per INSERT). That inherently speeds things up 10-fold because of amortizing the statement overhead (Added By @Rick James in comments)

I know two side effects for this method.

  1. undo log will get too large while performing this operation.
  2. If an error happen during the operation, the entire import will be reverted (which might be an advantage in your case).