On Fri, Jun 20, 2008 at 7:26 PM, Brion Vibber <brion(a)wikimedia.org> wrote:
There is an urban legend that count(field) is faster
than count(*),
since it doesn't have to load all those fields specified by the '*'. I'm
pretty sure it's not actually true, though, and that the database knows
that '*' just means "count the rows" here. :)
In fact, Peter Zaitsev seems to find that COUNT(field) can be
significantly slower, because while MySQL is smart enough to pick any
unique NOT NULL index for COUNT(*), it can't always figure out that it
can do the same for COUNT(field):
http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/