what is the difference between the select count(*)
and select count(true)
?
so is there any different between the count(*)
and count(true)
which one should I use?
can you give me situation example for each one that is better option to choose?
Advertisement
Answer
The result of both is the same, but count(*)
is slightly faster than count(true)
. That is because in the first case, the aggregate function has no arguments (that’s what the *
means in SQL), whereas in the second case the argument true
is checked for NULLness, since count
skips rows where the argument is NULL.