Re: Use generation context to speed up tuplesorts - Mailing list pgsql-hackers

From David Rowley
Subject Re: Use generation context to speed up tuplesorts
Date
Msg-id CAApHDvqUY3Nb-Yfcd0A4GRX7ce-YL3rOm4emH-hFwpmmDjVf0w@mail.gmail.com
Whole thread Raw
In response to Re: Use generation context to speed up tuplesorts  (Andres Freund <andres@anarazel.de>)
Responses Re: Use generation context to speed up tuplesorts  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Sat, 31 Jul 2021 at 08:38, Andres Freund <andres@anarazel.de> wrote:
> There is at least one path using tuplecontext that reaches code that
> could end up freeing memory to a significant enough degree to care about
> generation.c effectively not using that memory:
> tuplesort_putdatum()->datumCopy()->EOH_flatten_into()
> On a quick look I didn't find any expanded record user that frees
> nontrivial amounts of memory, but I didn't look all that carefully.

I guess we could just use a normal context for datum sorts if we
thought that might be a problem.

I'm not too familiar with the expanded object code, but I'm struggling
to imagine why anything would need to do a pfree in there. We just do
EOH_get_flat_size() to determine how big to make the allocation then
allocate some memory for EOH_flatten_into() to use to expand the
object into.

David



pgsql-hackers by date:

Previous
From: "Bossart, Nathan"
Date:
Subject: Re: make MaxBackends available in _PG_init
Next
From: Mike Klaas
Date:
Subject: Re: disfavoring unparameterized nested loops