Re: count(*) vs count(id)
От | Guillaume Lelarge |
---|---|
Тема | Re: count(*) vs count(id) |
Дата | |
Msg-id | CAECtzeVpR8yvP+S3J++MEJ7dsmsiEX2kxToBmHdJrrXz+zxzpQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: count(*) vs count(id) (Matt Zagrabelny <mzagrabe@d.umn.edu>) |
Ответы |
Re: count(*) vs count(id)
|
Список | pgsql-general |
Le mar. 2 févr. 2021 à 02:14, Matt Zagrabelny <mzagrabe@d.umn.edu> a écrit :
On Mon, Feb 1, 2021 at 6:35 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:Matt Zagrabelny <mzagrabe@d.umn.edu> writes:
> On Mon, Feb 1, 2021 at 5:57 PM Rob Sargent <robjsargent@gmail.com> wrote:
>> You got one null from count(*) likely.
> What is count(*) counting then? I thought it was rows.
Yeah, but count(id) only counts rows where id isn't null.I guess I'm still not understanding it...I don't have any rows where id is null:$ select count(*) from call_records where id is null;
count
═══════
0
(1 row)
Time: 0.834 ms
$select count(id) from call_records where id is null;
count
═══════
0
(1 row)
Time: 0.673 msWhich field is count(*) counting if it is counting nulls?
You're doing a left join, so I guess there's no row where call_records.timestamp::date = 2020-08-30. That would result with a NULL id.
Guillaume
В списке pgsql-general по дате отправления: