当前位置:网站首页>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
边栏推荐
- CKA certification notes - CKA certification experience post
- BeanDefinitionRegistryPostProcessor
- Kubesphere - Multi tenant management
- Deep learning, thinking from one dimensional input to multi-dimensional feature input
- Leetcode problem solving summary, constantly updating!
- C 语言文件操作函数大全 (超详细)
- 智牛股--03
- Phpstudy setting items can be accessed by other computers on the LAN
- Detailed explanation of iptables (1): iptables concept
- 理解 期望(均值/估计值)和方差
猜你喜欢

Pytorch builds the simplest version of neural network

Kubernetes notes (I) kubernetes cluster architecture

Clickhouse learning notes (2): execution plan, table creation optimization, syntax optimization rules, query optimization, data consistency

Core principles and source code analysis of disruptor

Convolution operation in convolution neural network CNN

Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception

Bernoulli distribution, binomial distribution and Poisson distribution, and the relationship between maximum likelihood (incomplete)
![[function explanation (Part 1)] | | knowledge sorting + code analysis + graphic interpretation](/img/c2/991b8febd262cf9237017adc9d1221.jpg)
[function explanation (Part 1)] | | knowledge sorting + code analysis + graphic interpretation
![[explain in depth the creation and destruction of function stack frames] | detailed analysis + graphic analysis](/img/df/884313a69fb1e613aec3497800f7ba.jpg)
[explain in depth the creation and destruction of function stack frames] | detailed analysis + graphic analysis

tabbar的设置
随机推荐
If function of MySQL
tabbar的设置
The programmer shell with a monthly salary of more than 10000 becomes a grammar skill for secondary school. Do you often use it!!!
Understand one-way hash function
Synthetic keyword and NBAC mechanism
Understand the first prediction stage of yolov1
SVN分支管理
智牛股--03
It is said that the operation and maintenance of shell scripts are paid tens of thousands of yuan a month!!!
1. Somme des deux nombres
Migrate data from Mysql to tidb from a small amount of data
Oauth2.0 - Introduction and use and explanation of authorization code mode
最大似然估计,散度,交叉熵
pytorch 搭建神经网络最简版
[Zhao Yuqiang] deploy kubernetes cluster with binary package
Kubesphere - Multi tenant management
Personal outlook | looking forward to the future from Xiaobai's self analysis and future planning
Kubernetes notes (I) kubernetes cluster architecture
Deep learning, thinking from one dimensional input to multi-dimensional feature input
How to create and configure ZABBIX