pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: aNullValue (Drew Stemen) <drew@anullvalue.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: count(*) vs count(id)
Date: Mon, 01 Feb 2021 20:17:50 -0500
Message-ID: <201e6c65-2d90-44f0-8b72-75cc5d9f36fd@www.fastmail.com> (raw)
In-Reply-To: <CAOLfK3XBUxP3jbAnKVn9cei4hh4snozhVj5yjxCipVnYvwfTsA@mail.gmail.com>
References: <CAOLfK3VWa_Mv3OSumvpHZdppd+qDj8EUWCdxY5+vUe=gAo+h0A@mail.gmail.com>
	<cb465259-e29a-8fc2-1890-2666b8d79f36@gmail.com>
	<CAOLfK3W99Cdf9Sq+XyJv5MAjp9wsYBKpAC2UAVp7+dB881KmjQ@mail.gmail.com>
	<3502043.1612226098@sss.pgh.pa.us>
	<CAOLfK3XBUxP3jbAnKVn9cei4hh4snozhVj5yjxCipVnYvwfTsA@mail.gmail.com>

At 2021-02-01T20:14:04-05:00, Matt Zagrabelny <mzagrabe@d.umn.edu> sent:
> select count(id) from call_records where id is null;
>  count 
> ═══════
>      0
> (1 row)
> 
> Time: 0.673 ms
> 
> Which field is count(*) counting if it is counting nulls?
> 
> -m

What you're overlooking is that, at least to my reading of your original query, id would be null for any dates that do not have any corresponding call_records (because you used a left join). 

view thread (14+ messages)  latest in thread

Message-ID: <201e6c65-2d90-44f0-8b72-75cc5d9f36fd@www.fastmail.com>
Permalink:  ../201e6c65-2d90-44f0-8b72-75cc5d9f36fd@www.fastmail.com/
Also on:    postgresql.org/message-id/201e6c65-2d90-44f0-8b72-75cc5d9f36fd@www.fastmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: drew@anullvalue.net
  Subject: Re: count(*) vs count(id)
  In-Reply-To: <201e6c65-2d90-44f0-8b72-75cc5d9f36fd@www.fastmail.com>
  References: <CAOLfK3VWa_Mv3OSumvpHZdppd+qDj8EUWCdxY5+vUe=gAo+h0A@mail.gmail.com> <cb465259-e29a-8fc2-1890-2666b8d79f36@gmail.com> <CAOLfK3W99Cdf9Sq+XyJv5MAjp9wsYBKpAC2UAVp7+dB881KmjQ@mail.gmail.com> <3502043.1612226098@sss.pgh.pa.us> <CAOLfK3XBUxP3jbAnKVn9cei4hh4snozhVj5yjxCipVnYvwfTsA@mail.gmail.com> <201e6c65-2d90-44f0-8b72-75cc5d9f36fd@www.fastmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox