Home > Backend Development > PHP Tutorial > mysql count 怎么提交效率

mysql count 怎么提交效率

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:24:39
Original
1306 people have browsed it

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

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

回复内容:

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

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

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

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

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template