I don't know how it works for other RDBMS, but for #PostgreSQL, it is a myth. Count(*) won't be slower that count(name) or count(1).
The planner will come with exactly the same plan.
I've tested this on occasion in the past. The problem is that the relative performance in benchmarks will depend wholly on the fraction of the time attributable to count(), so it's never the same between different queries.
-
-
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
- 6 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.

