Page 1 of 1

Major difference between COUNT(column_name) and COUNT(*)

Posted: Thu Oct 18, 2012 5:53 pm
by Fidbeck
For example if I wanted to count elements in a specific table
I can use
SELECT COUNT(user_id) FROM `users`
and
SELECT COUNT(user_id) FROM `users`
the give the same number but what are the main differences between them?

Re: Major difference between COUNT(column_name) and COUNT(*)

Posted: Thu Oct 18, 2012 5:56 pm
by jacek
The difference is generally performance on large tables, this explains it rather well http://www.mysqlperformanceblog.com/200 ... -countcol/

Re: Major difference between COUNT(column_name) and COUNT(*)

Posted: Thu Oct 18, 2012 6:00 pm
by Fidbeck
My table is not that big it has over 100 users, so I can use either. but for the sake of speed count(*) is faster

Thanks