From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: Surprising benchmark count(1) vs. count(*)
Date: Thu, 19 Sep 2019 10:11:52 -0400
Message-ID: <22758.1568902312@sss.pgh.pa.us> (raw)
In-Reply-To: <35f81ca4-f68e-8b71-d34c-7364751b4e36@gmx.net>
References: <df354b76-a645-73fc-9645-4508e5291d71@gmx.net>
<ab88db80f032933ff603d9d59745e8a09196bc1e.camel@cybertec.at>
<35f81ca4-f68e-8b71-d34c-7364751b4e36@gmx.net>
Thomas Kellerer <spam_eater@gmx.net> writes:
> Laurenz Albe schrieb am 19.09.2019 um 12:22:
>> "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?
[ shrug... ] There's no special optimization for that case.
And I can't say that it seems attractive to add one.
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, spam_eater@gmx.net, pgsql-performance@lists.postgresql.org
Subject: Re: Surprising benchmark count(1) vs. count(*)
In-Reply-To: <22758.1568902312@sss.pgh.pa.us>
* 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