前段时间,一大早上,就收到报警,警告php-fpm进程的数量超过阈值。最终发现是一条sql没用到索引,导致执行数据库查询慢了,最终导致php-fpm进程数增加。最终通过analyze table feed_comment_info_id_0000 命令更新了Cardinality ,才能再次用到索引。
排查过程如下:
sql语句:
select id from feed_comment_info_id_0000 where obj_id=101 and type=1;
索引信息:
show index from feed_comment_info_id_0000 +---------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | …[获取更多]