Re: count(*) vs count(id)

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Matt Zagrabelny <mzagrabe(at)d(dot)umn(dot)edu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Rob Sargent <robjsargent(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: count(*) vs count(id)
Date: 2021-02-02 01:16:50
Message-ID: CAKFQuwa2ki4CyncgrMWqR8aewxfhPjtXX4fy+89yrWsDms+Upg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Feb 1, 2021 at 6:14 PM Matt Zagrabelny <mzagrabe(at)d(dot)umn(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message aNullValue (Drew Stemen) 2021-02-02 01:17:50 Re: count(*) vs count(id)
Previous Message Matt Zagrabelny 2021-02-02 01:14:04 Re: count(*) vs count(id)