[Solved] Is mysql count(*) much less efficient than count(specific_field)? [duplicate]


For InnoDB

If specific_field is not nullable, they are equivalent and have the same performance.

If specific_field is nullable, they don’t do the same thing. COUNT(specific_field) counts the rows which have a not null value of specific_field. This requires looking at the value of specific_field for each row. COUNT(*) simply counts the number of rows and in this case can be faster as it does not require examining the value of specific_field.

For MyISAM

There is a special optimization for the following so that it does not even need to fetch all rows:

SELECT COUNT(*) FROM yourtable

3

solved Is mysql count(*) much less efficient than count(specific_field)? [duplicate]