Brandie Tarvin (2/6/2015)[hr
I think the argument here isn't "why NOT to use COUNT(*)" or "why to use COUNT(1)". It's more along the lines of "use either, the result and the query execution will be the same."
This is where I disagree quite strongly.
Yes the 2 options are functionally equivalent and have identical performance.
But claiming that therefore it doesn't matter which is used completely ignores the consideration of code maintainability.
Of the 2 options COUNT(*) and COUNT(1), which more intuitively implies "count all rows" versus "count one".
Any developer who doesn't happen to know the peculiarity of the COUNT(1) syntax will do a double-take.
The developer (if of the sort who'll do a proper due diligence) would have to spend time doing further investigation to understand what's going on and confirm that there are no unforeseen negative effects. <--- This immediately makes COUNT(1) an inferior choice.