Is there a difference between the following queries, assuming there is a primary field 'id' in the table (as in speed, etc)?
SELECT COUNT(id)
FROM table
vs.
SELECT COUNT(*)
FROM table
Is there a difference between the following queries, assuming there is a primary field 'id' in the table (as in speed, etc)?
SELECT COUNT(id)
FROM table
vs.
SELECT COUNT(*)
FROM table
I know this is several years old but I don't see any evidence on which one to use, so I will post here my findings.
Executing explain in MySql Workbench for an InnoDB table on MySql 5.7 I see the following:
As you can see, both results are identical, so for this scenario both expressions are equivalent