From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Cc: Maksim Milyutin <milyutinma@gmail.com>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Subject: Re: Proposal: Local indexes for partitioned table
Date: Fri, 27 Oct 2017 17:25:43 -0400
Message-ID: <12195.1509139543@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoZ6z8+PqygTR=yC=tFCMJ6uUYWTLFKTSKXaHu=jYCjLLg@mail.gmail.com>
References: <20171023151251.j75uoe27gajdjmlm@alvherre.pgsql>
<20171027172730.eh2domlkpn4ja62m@alvherre.pgsql>
<CA+TgmoZ6z8+PqygTR=yC=tFCMJ6uUYWTLFKTSKXaHu=jYCjLLg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Robert Haas <robertmhaas@gmail.com> writes:
> On Fri, Oct 27, 2017 at 7:27 PM, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
>> I noticed that RelationBuildPartitionKey is generating a partition key
>> in a temp context, then creating a private context and copying the key
>> into that. That seems leftover from some previous iteration of some
>> other patch; I think it's pretty reasonable to create the new context
>> right from the start and allocate the key there directly instead. Then
>> there's no need for copy_partition_key at all.
> We could do that, but the motivation for the current system was to
> avoid leaking memory in a long-lived context. I think the same
> technique is used elsewhere for similar reasons. I admit I haven't
> checked whether there would actually be a leak here if we did it as
> you propose, but I wouldn't find it at all surprising.
Another key point is to avoid leaving a corrupted relcache entry behind
if you fail partway through. I think that the current coding is
RelationBuildPartitionKey is safe, although it's far too undercommented
for my taste. (The ordering of the last few steps is *critical*.)
It might work to build the new key in a context that's initially a
child of CurrentMemoryContext, then reparent it to be a child of
CacheMemoryContext when done. But you'd have to look at whether that
would end up wasting long-lived memory, if the build process generates
any cruft in the same context.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, alvherre@alvh.no-ip.org, milyutinma@gmail.com, Langote_Amit_f8@lab.ntt.co.jp
Subject: Re: Proposal: Local indexes for partitioned table
In-Reply-To: <12195.1509139543@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox