一个数据表数据有几十万的样子 在查询页面反复的时候 CPU特别高基本爆满
SQl语句
select count(*) from emp where catid <> 3 and cid =2; 用户做分页数量
select * from emp limit 1,10; 本页显示的
一个数据表数据有几十万的样子 在查询页面反复的时候 CPU特别高基本爆满
SQl语句
select count(*) from emp where catid <> 3 and cid =2; 用户做分页数量
select * from emp limit 1,10; 本页显示的
InnoDB是没有直接保存表的数据总数的,select count(*) from emp;
要扫一遍索引,反复查当然要耗CPU。
我的测试表有两千万数据,没缓存时count(*)
要15秒,有缓存后也要3秒。
show table status where Name = 'your table name'
可以拿到近似的行数。
5 回答3.2k 阅读✓ 已解决
3 回答3.6k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
5 回答1.4k 阅读
3 回答1.2k 阅读✓ 已解决
2 回答2k 阅读
3 回答2k 阅读
你这个根本没有访问索引,直接读硬盘数据