Understanding COUNT(*) vs COUNT(1) in SQL

COUNT(*) and COUNT(1) serve to count rows in SQL, yielding the same results but with nuanced internal processing. Modern SQL engines treat both functions similarly, resulting in negligible performance differences. COUNT(*) is preferred for clarity, while COUNT(1) is used out of habit. COUNT(column_name) counts non-NULL values in a specific column.

Blog at WordPress.com.

Up ↑