Re: json(b)_array_elements use causes very large memory usage when also referencing entire json document

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Lucas Fairchild-Madar <lucas(dot)madar(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: json(b)_array_elements use causes very large memory usage when also referencing entire json document
Date: 2017-10-07 00:36:20
Message-ID: 2714.1507336580@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andres Freund <andres(at)anarazel(dot)de> writes:
> On 2017-10-06 15:37:03 -0400, Tom Lane wrote:
>> 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.

BTW, another idea that occurred to me is to change things so we only
evaluate scalar tlist items once per SRF cycle, and just re-use their
old values for additional SRF output rows. However, to preserve current
semantics we'd have to distinguish volatile vs. non-volatile tlist items,
and be sure to do the former over again for each SRF output row. So
I'm not really excited about that, because of the amount of complexity
it would add. This is messy enough without having two code paths for
the scalar items ... and we'd still have the memory leak issue in the
volatile case.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2017-10-07 00:36:54 Re: json(b)_array_elements use causes very large memory usage when also referencing entire json document
Previous Message Tom Lane 2017-10-07 00:28:21 Re: json(b)_array_elements use causes very large memory usage when also referencing entire json document