From 08b9a1fdd6ab0ec67ccbe310df0bf0b64854b46c Mon Sep 17 00:00:00 2001 From: "Andrei V. Lepikhov" 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. + + Aggregate function calls can also be simplified during planning. For + example, COUNT(x) can be + replaced by COUNT(*) + when x is known not to be null. This can be + done by a support function that implements + the SupportRequestSimplifyAggref 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 + SupportRequestSimplify, it is the support function's + responsibility that the replacement be equivalent to normal execution of the + target aggregate. + + For target functions that return boolean, it is often useful to estimate the fraction of rows that will be selected by a WHERE clause using that -- 2.55.0