insert into sms_coupon (type,name,platform,count,amount,per_limit,min_point,start_time, end_time)
SELECT type,name,platform,count,amount,per_limit,min_point,start_time, end_time FROM `sms_coupon`
update sms_coupon set type= CONCAT(FLOOR(RAND() * 1000) + 1) ,
platform = CONCAT(FLOOR(RAND() * 1000) + 1), count = CONCAT(FLOOR(RAND() * 1000) + 1),
min_point = CONCAT(FLOOR(RAND() * 1000) + 1)
-- 索引不起作用:重复值太多,使用比较符号> <
-- 2.037,1.8,加了索引4,5秒 --没有太多重复值,1.2s,加了索引0.027(如果是大于小于,索引失效)
explain(
select * from sms_coupon
where name = '小米手机专用券' and type=448 )
-- 增加索引
alter table sms_coupon
add index zuhe_index(type,name,platform,count,min_point)
-- 删除索引
alter table sms_coupon drop index zuhe_index
select CONCAT(FLOOR(RAND() * 100000) + 1);
加了索引:
没加索引: