mysql count 怎么提交效率


有一个程序,先从user表查一定数量的用户$data,再foreach数组,从user表里count(*) where pid=$value['id'] 来统计子集数量

循环200条数据需要5秒多,要是数据多估计就卡死了,该怎么优化?

php mysql

Falken 8 years, 5 months ago

用Count(1)而不是count(*)可以有一定改善

就烦起名字 answered 8 years, 5 months ago

连接查询count(*)使用group by

阿酱的小池 answered 8 years, 5 months ago

Your Answer