On Mon, Jan 26, 2026 at 12:44 AM Tom Lane <[email protected]> wrote:
>
> David Rowley <[email protected]> writes:
> > On Sun, 25 Jan 2026 at 19:48, Junwang Zhao <[email protected]> wrote:
> >> In [1], David Rowley noted that COUNT(NULL) can be replaced
> >> with '0'::bigint. The change should be straightforward, and I came
> >> up with the attached patch to implement it.
>
> > Coming up with the code to do this wasn't the problem. I already
> > posted it in the patch in [2]. The reason I didn't commit that part is
> > simply that I don't think anyone would ever write COUNT(NULL) in a
> > query.
>
> Yeah, I agree that this should be so rare as to not be worth expending
> planner cycles to check for, not to mention future code maintenance
> costs.  The other special cases we optimize COUNT() for are common
> real-world usages, but not this.

Agreed, good to know, thanks for the explanation.

>
>                         regards, tom lane



-- 
Regards
Junwang Zhao


Reply via email to