利用MySQL存储过程批量插入100W条测试数据

DROP PROCEDURE IF EXISTS insert_batch;
CREATE PROCEDURE insert_batch()
BEGIN
   DECLARE n int DEFAULT 1;
        loopname:LOOP
            INSERT INTO `mlcloud`.`vm_snapshots` (`task_id`, `size`, `time_used`, `create_time`) VALUES ('148', '431644213248', '447', '1556041462');
            SET n=n+1;
        IF n=1000000 THEN
            LEAVE loopname;
        END IF;
        END LOOP loopname;
END;

CALL insert_batch();

总耗时:

[SQL]

CALL insert_batch();
受影响的行: 1
时间: 873.795s

上一篇:原创|为什么你总是坚持不下来做一件事?


下一篇:魔兽争霸3作弊码