COUNT(1) is faster than COUNT(*).
COUNT(*) takes all columns to count rows and COUNT(1) counts using the first column
COUNT (<expression>)
COUNT function counts all of not empty (non-null) occurrences of expression <expression>.
COUNT(1) is nothing other than COUNT(<expression>) where the Expression = 1 => and „1” is obviously not null.
COUNT(*)
There is not too much to explain – it just counts all records in table.
For Example
EMP Table Data.
COUNT(*) takes all columns to count rows and COUNT(1) counts using the first column
COUNT (<expression>)
COUNT function counts all of not empty (non-null) occurrences of expression <expression>.
COUNT(1) is nothing other than COUNT(<expression>) where the Expression = 1 => and „1” is obviously not null.
COUNT(*)
There is not too much to explain – it just counts all records in table.
For Example
EMP Table Data.
select count(*) , count(1),count(comm) from emp
No comments:
Post a Comment