When we execute select count(*) from table_name it returns the number of rows.
select count(*) from table_name
What does count(1) do? What does 1 signify here
count(1)
1
Here is a link that will help answer your questions. In short:
count(*) is the correct way to write it and count(1) is OPTIMIZED TO BE count(*) internally -- since a) count the rows where 1 is not null is less efficient than b) count the rows
count(*) is the correct way to write it and count(1) is OPTIMIZED TO BE count(*) internally -- since
a) count the rows where 1 is not null is less efficient than b) count the rows