Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*)

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*)
Date: 2025-11-25 23:37:50
Message-ID: CAApHDvrde9DUpQ3DhPd3ia9tchVmhZqewfzxSYWmYFWVj=LPpg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 5 Nov 2025 at 13:16, David Rowley <dgrowleyml(at)gmail(dot)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 Content-Type Size
v4-0001-Have-the-planner-replace-COUNT-ANY-with-COUNT-whe.patch application/octet-stream 22.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Manni Wood 2025-11-26 00:09:42 Re: Speed up COPY FROM text/CSV parsing using SIMD
Previous Message Peter Smith 2025-11-25 23:24:27 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart