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

2022-10-18,,,,

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

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

下载本文的Word格式文档,以方便收藏与打印。