I need to insert millions of rows into a MySQL database (InnoDB engine). I have a problem with time when the tables are large. Almost all the time is spent on insert requests. Can anyone know how to optimize it?
To import most of the data into InnoDB:
installed in MySQL configuration
Add immediately after the start of the transaction:
SET FOREIGN_KEY_CHECKS = 0;
SET UNIQUE_CHECKS = 0;
SET AUTOCOMMIT = 0;
Install right before the transaction ends:
SET UNIQUE_CHECKS = 1;
SET FOREIGN_KEY_CHECKS = 1;
INSERT, , . , ( ) , SQL. , . , - , .
INSERT