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
From 08b9a1fdd6ab0ec67ccbe310df0bf0b64854b46c Mon Sep 17 00:00:00 2001
From: "Andrei V. Lepikhov" <[email protected]>
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.sgml
index 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 via email to