mysql+distinct+max_MySQL中distinct与group by之间的性能进行比较

最近在网上看到了一些测试,感觉不是很准确,今天亲自测试了一番。得出了结论,测试过程在个人计算机上,可能不够全面,仅供参考。

测试过程:

准备一张测试表

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(

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值