select count(1) from table s where 1=1
总行数31万,这条sql耗时几十秒,太不正常了,executing这一步到底在做什么,谢谢。
先解析一下每一个状态的意义:
starting:开始checking permissions:检查权限Opening tables:打开表init : 初始化System lock :系统锁optimizing : 优化statistics : 统计preparing :准备executing :执行Sending data :发送数据Sorting result :排序end :结束query end :查询 结束closing tables : 关闭表 /去除TMP 表
executing 是在真正的执行这条 SQL---select count(1) from table s where 1=1,查询 table 这个表的数量,走的全表扫描
可能存在的原因
1、数据量31w
2、可能是机器的性能