Which query is faster, select count(*) or count(pk)?
HyeontaeJu
Vertica Customer ✭
Which query is faster, select count(*) or count(pk)?
0
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