From 9f7d2e715a707c2d793f5ee99a6d25938ef69090 Mon Sep 17 00:00:00 2001 From: Andrei Lepikhov Date: Wed, 19 Aug 2026 17:34:13 +0000 Subject: [PATCH 1/2] Document the SupportRequestSimplifyAggref support request The request has been in supportnodes.h since 42473b3b312, but the documentation was not updated, so the only description of it is the header comment. Author: Andrei Lepikhov Discussion: https://postgr.es/m/ca4ee281-f75b-445b-b57f-0b560067c1d7@gmail.com --- 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 050e1e50bec..99be010f89f 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.52.0