当前位置:网站首页>About the difference between count (1), count (*), and count (column name)
About the difference between count (1), count (*), and count (column name)
2022-07-03 06:07:00 【vincentwc】
count(1) and count(*) There is no difference .
count( Column ) and count(*) It's actually as fast , If the index column is not empty ,count(*) Available to index , Just as fast at this time .
summary : But is the conclusion really like this . It's not . In fact, in the database count(*) and count( Column ) It is simply not equivalent ,count(*) It is aimed at the whole table , and count( Column ) It is for a certain column , If this column value is empty ,count( Column ) I won't count this line . So there is no comparability between the two , Performance comparison should first consider writing equivalence , These two statements are not equivalent at all . It will lose the significance of comparison !!!
If the query table has only one field , be COUNT(*) The fastest ;
If the query table has no primary key , be COUNT(1) Than COUNT(*) fast ;
If the query table has a primary key , be COUNT( Primary key ) Than COUNT(*) fast ,count( Primary key column )》count(1)》count(*);
COUNT(*) Return the total number of rows , contain NULL value ; COUNT( Name ) Return the total number of rows , Not included NULL value ; DISTINCT COUNT(*) Return the total number of rows , Remove duplicates without NULL value
边栏推荐
- PMP笔记记录
- [set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
- [branch and cycle] | | super long detailed explanation + code analysis + a trick game
- Merge and migrate data from small data volume, sub database and sub table Mysql to tidb
- Oauth2.0 - user defined mode authorization - SMS verification code login
- Kubernetes notes (VI) kubernetes storage
- Oauth2.0 - explanation of simplified mode, password mode and client mode
- Ext4 vs XFS -- which file system should you use
- Get a screenshot of a uiscrollview, including off screen parts
- Multithreading and high concurrency (7) -- from reentrantlock to AQS source code (20000 words, one understanding AQS)
猜你喜欢
![[function explanation (Part 1)] | | knowledge sorting + code analysis + graphic interpretation](/img/c2/991b8febd262cf9237017adc9d1221.jpg)
[function explanation (Part 1)] | | knowledge sorting + code analysis + graphic interpretation

从小数据量分库分表 MySQL 合并迁移数据到 TiDB

伯努利分布,二项分布和泊松分布以及最大似然之间的关系(未完成)

Simple solution of small up main lottery in station B

Jedis source code analysis (II): jediscluster module source code analysis

项目总结--01(接口的增删改查;多线程的使用)
![[advanced pointer (2)] | [function pointer, function pointer array, callback function] key analysis + code explanation](/img/9b/a309607c037b0a18ff6b234a866f9f.jpg)
[advanced pointer (2)] | [function pointer, function pointer array, callback function] key analysis + code explanation

Kubernetes notes (II) pod usage notes

轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷

Understand expectations (mean / estimate) and variances
随机推荐
MySQL带二进制的库表导出导入
Mysql database table export and import with binary
Understand one-way hash function
从小数据量分库分表 MySQL 合并迁移数据到 TiDB
Life is a process of continuous learning
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
[teacher Zhao Yuqiang] Flink's dataset operator
Exportation et importation de tables de bibliothèque avec binaires MySQL
What's the difference between using the Service Worker Cache API and regular browser cache?
【系统设计】邻近服务
88. Merge two ordered arrays
Migrate data from Mysql to tidb from a small amount of data
Personal outlook | looking forward to the future from Xiaobai's self analysis and future planning
多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)
卷积神经网络CNN中的卷积操作详解
[teacher Zhao Yuqiang] index in mongodb (Part 1)
Cesium entity(entities) 实体删除方法
MySQL帶二進制的庫錶導出導入
Skywalking8.7 source code analysis (I): agent startup process, agent configuration loading process, custom class loader agentclassloader, plug-in definition system, plug-in loading
Kubernetes notes (II) pod usage notes