Definitely select count(1) is too much faster,
The count(pk) is equal to select count(1) where pk is not null,
In my case select count(1) takes 200ms but the select count(id) takes more than 20 seconds (the table has more than 10B records)!
Also i think select count(1) and select count(*) are same
Answers
Definitely
select count(1)
is too much faster,The
count(pk)
is equal toselect count(1) where pk is not null
,In my case
select count(1)
takes 200ms but theselect count(id)
takes more than 20 seconds (the table has more than 10B records)!Also i think
select count(1)
andselect count(*)
are same