Re: count(*) vs count(id) - Mailing list pgsql-general

From David G. Johnston
Subject Re: count(*) vs count(id)
Date
Msg-id CAKFQuwa2ki4CyncgrMWqR8aewxfhPjtXX4fy+89yrWsDms+Upg@mail.gmail.com
Whole thread Raw
In response to Re: count(*) vs count(id)  (Matt Zagrabelny <mzagrabe@d.umn.edu>)
List pgsql-general
On Mon, Feb 1, 2021 at 6:14 PM Matt Zagrabelny <mzagrabe@d.umn.edu> wrote:
Which field is count(*) counting if it is counting nulls?

count(id) excludes from the count rows where the id field is null.  The presence of a left join in your query is introducing a null here due to there not being a related field, not because the id value in a table is actually null.

David J.

pgsql-general by date:

Previous
From: Matt Zagrabelny
Date:
Subject: Re: count(*) vs count(id)
Next
From: "aNullValue (Drew Stemen)"
Date:
Subject: Re: count(*) vs count(id)