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

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Lucas Fairchild-Madar <lucas.madar@gmail.com>, pgsql-bugs@postgresql.org
Date: 2017-10-08T21:13:11Z
Lists: pgsql-bugs
On 2017-10-08 16:27:51 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > On 2017-10-06 21:08:43 -0700, Andres Freund wrote:
> >> I'm kinda tempted to put this, after a bit more testing, into v10.
> 
> > Any opinions on that?
> 
> I think it's fine to put it in HEAD.  I would not risk back-patching
> into v10.  Now that we fixed the new leak, v10 is on par with the last
> umpteen years worth of tSRF behavior, and we've not had very many
> complaints about that.

WFM. Was only thinking about it, because it'd give the OP a chance to
upgrade to a supported release and get rid of the behaviour. But given
he's essentially hitting O(n^2) runtime even aftre that, just rewriting
the query is the saner option anyway...

Will make it so.

Greetings,

Andres Freund


Commits

  1. Reduce memory usage of targetlist SRFs.

  2. Fix intra-query memory leakage in nodeProjectSet.c.