What is the difference between COUNT(*), COUNT(1), and COUNT(column)?

Answer

These three forms count rows differently: COUNT(*) counts every row in the result set, including rows with NULL values in any column. It is the standard, most readable form and the recommended way to count rows. COUNT(1) counts the number of 1s (a non-NULL constant) in the result — effectively equivalent to COUNT(*) in all practical cases. Some people mistakenly believe COUNT(1) is faster than COUNT(*); in modern MySQL (and virtually all databases), the optimizer treats them identically. Use COUNT(*) for clarity. COUNT(column) counts the number of non-NULL values in that specific column. This is different — it excludes NULL values: SELECT COUNT(phone) FROM users counts only users who have a phone number. This is useful for counting how many rows have a value in an optional column. Summary: COUNT(*) = total rows; COUNT(col) = non-NULL values in that column; COUNT(DISTINCT col) = unique non-NULL values. For InnoDB tables, COUNT(*) without a WHERE clause requires a table scan (InnoDB doesn't store row counts like MyISAM) — this is why COUNT(*) can be slow on large tables. Solution: maintain a counter table or use approximate counts.