It will even be slightly faster because @PostgreSQL is kind of dumb here and will check for each row that 1 is still not null.
Picking a single query and measuring the overhead specific to count() (this isn't simple) suggests that in fact, count(1) is 50% slower than count(*): on the machine I tested on, this is roughly 4 ns for count(*) and 6 ns for count(1)
-
-
But the rest of the query usually drowns that out; e.g. in my tests that represented a difference of 2 seconds for a query taking 47 seconds
-
For example, consider the performance difference between "select count(1) from ...", "select count(1), count(2) from ...", and "select count(1), count(*) from ..." on the same input. (Note that the two count() calls MUST be different or they will be combined)
- 5 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.

