Re: AllocSetEstimateChunkSpace() - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: AllocSetEstimateChunkSpace()
Date
Msg-id b792193cb19cd348e84a5c5b3267a77a6f32edcc.camel@j-davis.com
Whole thread Raw
In response to AllocSetEstimateChunkSpace()  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: AllocSetEstimateChunkSpace()  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Tue, 2020-03-24 at 18:12 -0700, Jeff Davis wrote:
> I considered making it a method of a memory context, but the planner
> will call this function before the hash agg memory context is
> created.

I implemented this approach also; attached.

It works a little better by having access to the memory context, so it
knows set->allocChunkLimit. It also allows it  to work with the slab
allocator, which needs the memory context to return a useful number.
However, this introduces more code and awkwardly needs to use
CurrentMemoryContext when called from the planner (because the actual
memory context we're try to estimate for doesn't exist yet).

I slightly favor the previous approach (mentioned in the parent email) 
because it's simple and effective. But I'm fine with this one if
someone thinks it will be better for other use cases.

Regards,
    Jeff Davis


Attachment

pgsql-hackers by date:

Previous
From: Anna Akenteva
Date:
Subject: Re: [HACKERS] make async slave to wait for lsn to be replayed
Next
From: Tomas Vondra
Date:
Subject: Re: [HACKERS] advanced partition matching algorithm forpartition-wise join