From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Lucas Fairchild-Madar <lucas.madar@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: json(b)_array_elements use causes very large memory usage when also referencing entire json document
Date: Fri, 06 Oct 2017 20:28:21 -0400
Message-ID: <2219.1507336101@sss.pgh.pa.us> (raw)
In-Reply-To: <20171007002116.2fqr6z26byhsjwoe@alap3.anarazel.de>
References: <CAJmoq7OJ=ntoLRE0R8h+_Dt8KoNifDhQQua_w2y_d1e7T6nL-w@mail.gmail.com>
<1546.1507314635@sss.pgh.pa.us>
<CAJmoq7OmXJ_G87D_He5j9kRSraANsuV7Oatxg3bhMsuawvOJ3Q@mail.gmail.com>
<2376.1507315734@sss.pgh.pa.us>
<CAJmoq7MKcfk2+X8A5OeQqedg9rypGoesOOg2pJQ3SzfNBE22TA@mail.gmail.com>
<4514.1507318623@sss.pgh.pa.us>
<20171007002116.2fqr6z26byhsjwoe@alap3.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Andres Freund <andres@anarazel.de> writes:
> On 2017-10-06 15:37:03 -0400, Tom Lane wrote:
>> So a leak would occur in any case ... but it's particularly awful in
>> this case, because data->'id' involves detoasting the rather wide
>> value of "data", which is then promptly leaked.
> While not tackling the problem in a systematic manner, it seems like
> it'd be a good idea to free the detoasted column in this and related
> functions?
I think that's basically a dead-end solution. It amounts to saying
that no functions can leak memory, which is not a place we're ever
likely to get to, especially given that there's been no policy
favoring that in the past (with the narrow exception of btree
comparison functions).
>> As of v10, it might be possible to fix this for the tlist case
>> as well, by doing something like using a separate short-lived
>> context for the non-SRF tlist items.
> Yea, that should be quite doable, slightly annoying to need more than
> one expr context, but that seems unavoidable. Should even be doable for
> SFRM_ValuePerCall? SFRM_Materialize isn't a "central" problem, given it
> properly manages memory for the tuplestore and filling the tuplestore is
> an internal matter.
I'm not really convinced whether there's an issue for ValuePerCall SRFs.
We've not had complaints about them, and I would think we would if that
feature alone would create an issue. But I've not thought about it hard,
nor tested.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, lucas.madar@gmail.com
Subject: Re: json(b)_array_elements use causes very large memory usage when also referencing entire json document
In-Reply-To: <2219.1507336101@sss.pgh.pa.us>
References: <CAJmoq7OJ=ntoLRE0R8h+_Dt8KoNifDhQQua_w2y_d1e7T6nL-w@mail.gmail.com> <1546.1507314635@sss.pgh.pa.us> <CAJmoq7OmXJ_G87D_He5j9kRSraANsuV7Oatxg3bhMsuawvOJ3Q@mail.gmail.com> <2376.1507315734@sss.pgh.pa.us> <CAJmoq7MKcfk2+X8A5OeQqedg9rypGoesOOg2pJQ3SzfNBE22TA@mail.gmail.com> <4514.1507318623@sss.pgh.pa.us> <20171007002116.2fqr6z26byhsjwoe@alap3.anarazel.de> <2219.1507336101@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