Home  >  Article  >  Backend Development  >  SQL查询一张表的总记录数还有比这个更快的吗?该怎么解决

SQL查询一张表的总记录数还有比这个更快的吗?该怎么解决

WBOY
WBOYOriginal
2016-06-13 12:25:49701browse

SQL查询一张表的总记录数还有比这个更快的吗?
目前是echo mysql_result(mysql_query("select count(表ID) from 表 where 表Name='张三'",$conn),0);

目前的执行时间感觉不太满意啊

大叔大婶大姐大妹子 有更好的获取总数的方案吗?

别藏着掖着啊

万分感谢!
------解决思路----------------------
在 Name 字段上建索引
------解决思路----------------------
explain select count(表ID) from 表 where 表Name='张三
贴出结构分析下。

Statement:
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