我想插入 10 million
行到mysql表。但它完成了10小时12米13秒29毫秒。如何加快它?
这是我的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()) FROM 1 FOR 4), SUBSTR(MD5(RAND()) FROM 1 FOR 6));
SET i = i + 1;
END WHILE;
END;
CALL tmpproc();
暂无答案!
目前还没有任何答案,快来回答吧!