Looking at how people are using COUNT(*) and COUNT(col) it looks like most of them think they are synonyms and just using what they happen to like, while there is substantial difference in performance and even query result.
Lets look at the following series of examples:
PLAIN TEXT SQL:
- CREATE TABLE `fact` (
- `i` int(10) UNSIGNED NOT NULL,
- `val` int(11) DEFAULT NULL,
- `val2` int(10) UNSIGNED NOT NULL,
- KEY `i` (`i`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1
- mysql> SELECT count(*) FROM fact;
- +----------+
- | count(*) |
- +----------+
- | 7340032 |
- +----------+
- 1 row IN SET (0.00 sec)
- mysql> SELECT count(val) FROM fact; …