响应头信息: Array ( [http_status] => HTTP/1.1 200 OK [date] => Sun, 28 Dec 2025 08:24:27 GMT [content-type] => text/html; charset=utf-8 [content-length] => 24235 [connection] => keep-alive [server] => tRPC-Gateway [content-encoding] => gzip [vary] => Accept-Encoding [inews_trace_id] => 40396647091228162427 [inews-trace-id] => 40396647091228162427 [x-upstream-latency] => 5 [x-proxy-latency] => 1 [x-frame-options] => SAMEORIGIN [content-security-policy] => frame-ancestors none ) 内容长度:123256 bytes 详细信息: Array ( [http_code] => 200 [total_time] => 0.755405 [content_type] => text/html; charset=utf-8 [redirect_count] => 0 [effective_url] => https://www.qq.com/ [size_download] => 24235 ) count(*) count(1)哪个更快?_count(*) count(1)哪个更快?_湖南省怀化市沅陵县工埃呀化粪池清理股份公司
您好,欢迎访问我的网站官方网站!
服务电话:
/Welcome to our website
当前位置:当前位置: 首页 >

count(*) count(1)哪个更快?

时间:2025-06-25 14:40:14  来源:{dede:adminname/}   作者:   点击:

团队 code review 时,一位同事把 count(*)改成了 count(1),说这样性能更好。

真的是这样吗?今天通过源码和实测数据,把这个问题说透。

本文基于 MySQL 8.0.28 版本测试,不同版本的优化器行为可能有差异 三种 count 方式的本质区别先看看这三种写法在 MySQL 中到底做了什么: // 模拟MySQL处理count的伪代码 public class CountProcessor { // count(*) 的处理逻辑 public long countStar(Table table) { long count = 0; for …。

count(*)  count(1)哪个更快?
|粤IP*******|网站地图
版权所有
技术支持:百度
在线客服