In order to verify mysql query optimization, specifically generated on the one million or tens of millions of pieces of data.
1, construction of the table
-- ---------------------------- DROP TABLE IF EXISTS `user_test`; CREATE TABLE `user_test` ( id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键id', `user_name` VARCHAR(255) DEFAULT NULL COMMENT '用户名', `pass_word` VARCHAR(255) DEFAULT NULL COMMENT '密码' , A PRIMARY KEY (ID) ) ENGINE = INNODB the AUTO_INCREMENT = . 1 the COMMENT = ' user information table ' ;
2, FIG manually insert a Data:
3, sql insert the data, the data for each run once doubled!
INSERT INTO user_test (user_name, pass_word) SELECT MD5(RAND()), RAND(10000) FROM user_test
4, a result, one million data inserted just 28 seconds