What is the difference between COUNT(*) and COUNT(table.ColumnName)?
I always thought that it is faster to put a column name as a parameter for COUNT, but now when I think of it I really don't know because * means that the function counts rows, so probably there isn't any difference? Or maybe giving a specific column name even slows the process?
The difference between these two is not (primarily) performance. They count different things:
COUNT(*) counts the rows in your table.
COUNT(column) counts the entries in a column - ignoring null values.
Of course there will be performance differences between these two, but that is to be expected if they are doing different things. Especially when the column allows null-values, the query will take longer than on a column that does not (or COUNT(*)).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With