update call_record set duration=
case duration
when '-1' then '2'
else duration
end
where line_name='801' order by `time` desc limit 1
这个表有10几W数据, duration,line_name, time 都为索引,
现在这个语句耗时10几毫秒,我的系统其它语句都是0.3毫秒,请问怎么优化这个语句?
...全文
1949打赏收藏
帮忙优化一个mysql语句
update call_record set duration= case duration when '-1' then '2' else duration end where line_name='801' order by `time` desc limit 1 这个表有10几W数据, duration,line_name, time 都为索引, 现在这个语句耗时10几毫秒,我的系统其它语句都是0.3毫秒,请问怎么优化这个语句?
贴出你的
show index from call_record;
explain select * from call_record where line_name='801' order by `time` desc limit 1;
以供分析。
理论上创建了 index(line_name,time) 应该就已经非常优化了。