From: Andrei Lepikhov <lepihov@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Corey Huinker <corey.huinker@gmail.com>
Subject: Re: Allow a prosupport function to be attached to an aggregate
Date: Tue, 18 Aug 2026 14:36:53 +0200
Message-ID: <ca4ee281-f75b-445b-b57f-0b560067c1d7@gmail.com> (raw)
In-Reply-To: <1850b0e8-ec3b-47cb-bcba-5648a82280d4@gmail.com>
References: <8f58c96d-d3c7-4c0f-9898-116f00eeaff6@gmail.com>
<CAApHDvpE-_CnMOQ=Y8wveUk-MrUzsyR66fXGq+R7j_g4tmra8g@mail.gmail.com>
<1850b0e8-ec3b-47cb-bcba-5648a82280d4@gmail.com>
On 18/08/2026 08:31, Andrei Lepikhov wrote:
> On 18/08/2026 06:56, David Rowley wrote:
>> Is delaying this until v20 fine for you?
> Yes, I can do it manually in pg_catalog for now - rewriting prosupport and
> setting the dependency in the pg_depend. There’s no rush - it’s just about
> keeping things tidy.
However, I noticed that it is not documented yet.
There are also three other prosupport requests that are not documented. A quick
search showed that documentation usually depends on the author, so it makes
sense to add it now.
Since each was introduced at a different time and serves a different purpose, I
suggest we start by documenting SupportRequestSimplifyAggref, as I am more
familiar with it - see the patch in attachment.
--
regards, Andrei Lepikhov,
pgEdge
Attachments:v0-0001-Document-the-SupportRequestSimplifyAggref-support.patch (text/plain, 1.8K) download
From 08b9a1fdd6ab0ec67ccbe310df0bf0b64854b46c Mon Sep 17 00:00:00 2001
From: "Andrei V. Lepikhov" <lepihov@gmail.com>
Date: Tue, 18 Aug 2026 14:29:50 +0200
Subject: [PATCH v0] Document the SupportRequestSimplifyAggref support request
The request has been in supportnodes.h since 42473b3b312, but
documentation was not updated, so the only description of it is the
header comment.
---
doc/src/sgml/xfunc.sgml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgmlindex 2b8a11e7ad0..880edf24588 100644--- a/doc/src/sgml/xfunc.sgml+++ b/doc/src/sgml/xfunc.sgml@@ -4241,6 +4241,22 @@ supportfn(internal) returns internal
normal execution of the target function.
</para>
+ <para>+ Aggregate function calls can also be simplified during planning. For+ example, <literal>COUNT(<replaceable>x</replaceable>)</literal> can be+ replaced by <literal>COUNT(*)</literal>+ when <replaceable>x</replaceable> is known not to be null. This can be+ done by a support function that implements+ the <literal>SupportRequestSimplifyAggref</literal> request type. The+ support function will be called for each instance of its target aggregate+ found in a query parse tree. If it finds that the particular call can be+ replaced, it can build and return a new node, usually another aggregate+ call, leaving the node it was given unmodified. As with+ <literal>SupportRequestSimplify</literal>, it is the support function's+ responsibility that the replacement be equivalent to normal execution of the+ target aggregate.+ </para>+
<para>
For target functions that return <type>boolean</type>, it is often useful to estimate
the fraction of rows that will be selected by a <literal>WHERE</literal> clause using that
--
2.55.0
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-hackers@postgresql.org
Cc: lepihov@gmail.com, dgrowleyml@gmail.com, corey.huinker@gmail.com
Subject: Re: Allow a prosupport function to be attached to an aggregate
In-Reply-To: <ca4ee281-f75b-445b-b57f-0b560067c1d7@gmail.com>
References: <8f58c96d-d3c7-4c0f-9898-116f00eeaff6@gmail.com> <CAApHDvpE-_CnMOQ=Y8wveUk-MrUzsyR66fXGq+R7j_g4tmra8g@mail.gmail.com> <1850b0e8-ec3b-47cb-bcba-5648a82280d4@gmail.com> <ca4ee281-f75b-445b-b57f-0b560067c1d7@gmail.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