thanks for your suggestions weirdan and pimptastic, unfortunately I do not have such a big table, if anyone has got it you can post the results.
MySQL 4.0.25, MyISAM, table with ~120000 rows. There's no difference, both count(*) and count(id) finish in 0.00 sec. Id field is indexed (therefor row count is read directly from index).
SELECT COUNT(`id`) FROM `table`; -- is equivalent to
SELECT COUNT(*) FROM `table` WHERE `id` IS NOT NULL; -- and index over the `id` column will be used to evaluate WHERE condition
raghavan20 wrote:Do they store row value separately?
For some column types, yes.
MySQL manual wrote:
In some cases, a query can be optimized to retrieve values without consulting the data rows. If a query uses only columns from a table that are numeric and that form a leftmost prefix for some key, the selected values may be retrieved from the index tree for greater speed