How to speed up MySQL Insertion of millions of rows?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
0
I want to insert 10 million rows to MySQL table. But it completed in 10 h 12 m 13 s 29 ms. How to speed it up? Here is my SQL USE foo; DROP TABLE IF EXISTS tmp; CREATE TABLE tmp ( id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, school_id CHAR(4) NOT NULL, student_id CHAR(6) NOT NULL, INDEX school_id(school_id), INDEX student_id(student_id), INDEX school_id_and_student_id(school_id, student_id) ); DROP PROCEDURE IF EXISTS tmpproc; CREATE PROCEDURE tmpproc() BEGIN DECLARE i INT UNSIGNED DEFAULT 0; WHILE i < 10000000 DO INSERT INTO tmp (school_id, student_id) VALUES (SUBSTR(MD5(RAND