10.5.5 Bulk Data Loading for InnoDB Tables (original) (raw)

10.5.5 Bulk Data Loading for InnoDB Tables

These performance tips supplement the general guidelines for fast inserts in Section 10.2.5.1, “Optimizing INSERT Statements”.

SET autocommit=0;  
... SQL import statements ...  
COMMIT;  

The mysqldump option--opt creates dump files that are fast to import into an InnoDB table, even without wrapping them with theSET autocommit andCOMMIT statements.

SET unique_checks=0;  
... SQL import statements ...  
SET unique_checks=1;  

For big tables, this saves a lot of disk I/O becauseInnoDB can use its change buffer to write secondary index records in a batch. Be certain that the data contains no duplicate keys.

SET foreign_key_checks=0;  
... SQL import statements ...  
SET foreign_key_checks=1;  

For big tables, this can save a lot of disk I/O.

INSERT INTO yourtable VALUES (1,2), (5,5), ...;  

This tip is valid for inserts into any table, not justInnoDB tables.