On Wed, Aug 6, 2025 at 3:52 AM Richard Guo <[email protected]> wrote: > To avoid potential memory blowout risks from large partial aggregation > values, v18 avoids applying eager aggregation if any aggregate uses an > INTERNAL transition type, as this typically indicates a large internal > data structure (as in string_agg or array_agg). However, this also > excludes aggregates like avg(numeric) and sum(numeric), which are > actually safe to use with eager aggregation. > > What we really want to exclude are aggregate functions that can > produce large transition values by accumulating or concatenating input > rows. So I'm wondering if we could instead check the transfn_oid > directly and explicitly exclude only F_ARRAY_AGG_TRANSFN and > F_STRING_AGG_TRANSFN. We don't need to worry about json_agg, > jsonb_agg, or xmlagg, since they don't support partial aggregation > anyway.
This strategy seems fairly unfriendly towards out-of-core code. Can you come up with something that allows the author of a SQL-callable function to include or exclude the function by a choice that is under their control, rather than hard-coding something in PostgreSQL itself? -- Robert Haas EDB: http://www.enterprisedb.com
