Re: Surprising benchmark count(1) vs. count(*)

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Surprising benchmark count(1) vs. count(*)
Дата
Msg-id 35f81ca4-f68e-8b71-d34c-7364751b4e36@gmx.net
обсуждение исходный текст
Ответ на Re: Surprising benchmark count(1) vs. count(*)  (Laurenz Albe <laurenz.albe@cybertec.at>)
Ответы Re: Surprising benchmark count(1) vs. count(*)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
Laurenz Albe schrieb am 19.09.2019 um 12:22:
>> https://blog.jooq.org/2019/09/19/whats-faster-count-or-count1/
>>
>> Is there a reason why count(*) seems to be faster?
> 
> "count(*)" is just the SQL standard's way of saying what you'd
> normally call "count()", that is, an aggregate without arguments.
> 
> "count(1)" has to check if 1 IS NULL for each row, because NULL
> values are not counted.  "count(*)" doesn't have to do that.

But 1 is a constant, why does it need to check it for each row? 





В списке pgsql-performance по дате отправления:

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: Surprising benchmark count(1) vs. count(*)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Surprising benchmark count(1) vs. count(*)