SQL COUNT(*) Vs COUNT(column_name)





0/5 (0 vote)
Well, another major point is that the two variants serve different purposes by definition. -- Count rows where 'column_name' is NOT NULLSELECT COUNT(column_name) FROM Table_Name-- Count ALL rows in Table_Name SELECT COUNT(*) FROM Table_Name-- ... which you just as well can...
Well, another major point is that the two variants serve different purposes by definition.
-- Count rows where 'column_name' is NOT NULL
SELECT COUNT(column_name) FROM Table_Name
-- Count ALL rows in Table_Name
SELECT COUNT(*) FROM Table_Name
-- ... which you just as well can exchange with a constant
SELECT COUNT(1) FROM Table_Name
In other words, it's not "which one is faster", it's "which one serves the purpose".