最近在网上看到了一些测试,感觉不是很准确,今天亲自测试了一番。得出了结论,测试过程在个人计算机上,可能不够全面,仅供参考。
测试过程:
准备一张测试表
create table `test_test` (
`id` int(11) not null auto_increment,
`num` int(11) not null default '0',
primary key (`id`)
) engine=myisam default charset=utf8 auto_increment=1 ;
建个储存过程向表中插入10w条数据
create procedure p_test(pa int(11))
begin
declare max_num int(11) default 100000;
declare i int default 0;
declare rand_num int;
select count(id) into max_num from test_test;
while i < pa do
if max_num < 100000 then
select cast(rand()*100 as unsigned) into rand_num;
insert into test_test(num)values(rand_num);
end if;
set i = i +1;
end while;
end
调用存储过程插入数据
call p_test(