Re: Significant performance issues with array_agg() + HashAggregate plans on Postgres 17 - Mailing list pgsql-performance

From Jeff Davis
Subject Re: Significant performance issues with array_agg() + HashAggregate plans on Postgres 17
Date
Msg-id af12804ead9f0530c3946c849099c5ef35763527.camel@j-davis.com
Whole thread Raw
In response to Re: Significant performance issues with array_agg() + HashAggregate plans on Postgres 17  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-performance
On Sat, 2026-04-04 at 13:21 +1300, David Rowley wrote:
> A slight variation on this that I was thinking of would be to
> introduce a MemoryPool struct that could be tagged onto a
> MemoryContext which contains a pool_limit. A child MemoryContext
> would, by default, inherit its parent's MemoryPool. On malloc/free,
> if
> the owning context has a non-null MemoryPool, the MemoryPool's
> memory_allocated is updated. At a safe point in nodeAgg.c, we'd check
> if the pool limit has been reached. I assume there's some simple
> inline function that just checks if memory_allocated is greater than
> pool_limit. Doing it this way would mean there's no need to
> recursively propagate the mentioned child_mem_allocated field up the
> hierarchy, as there is only a single field to update if the
> MemoryPool
> field is set.

I like that idea, because it could also be a good place to hold a max
block size for that tree of contexts. That's important to ensure that
the block size is significantly less than work_mem.

But it also means there's only one pool in any given subtree (unless
you mean that we should make that work somehow), which is an awkward
requirement, especially with MemoryContextSetParent().

Regards,
    Jeff Davis




pgsql-performance by date:

Previous
From: Andreas Karlsson
Date:
Subject: Re: Linux 7.0 performance degradation
Next
From: Priya V
Date:
Subject: Async standby lag + physical slot + hot_standby_feedback=on appeared to degrade primary performance