Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*) - Mailing list pgsql-hackers

From David Rowley
Subject Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*)
Date
Msg-id CAApHDvrde9DUpQ3DhPd3ia9tchVmhZqewfzxSYWmYFWVj=LPpg@mail.gmail.com
Whole thread Raw
In response to Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*)  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-hackers
On Wed, 5 Nov 2025 at 13:16, David Rowley <dgrowleyml@gmail.com> wrote:
> I've attached a version with the NOT_USED part removed (and a bunch of
> #includes I forgot to remove). The only other change was a minor
> revision to some comments.

This patch needed to be rebased due to the changes made in b140c8d7a.
I also adjusted a few comments and adjusted some code in
simplify_aggref() which mistakenly assumed the support function would
always return an Aggref. That conflicted with what I'd written in the
header comment for the SupportRequestSimplifyAggref struct; "(probably
another Aggref)". Which is leaving the door open for more aggressive
optimisations that someone might want to do, e.g. the mentioned
COUNT(NULL) replaced with '0'::bigint.

I'm not seeing any reason now not to go ahead with this now. Does
anyone else want to take a look at it before I start wielding the
sword of commitment on it?

David

Attachment

pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Next
From: Manni Wood
Date:
Subject: Re: Speed up COPY FROM text/CSV parsing using SIMD