Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0d6X-0000W3-HN for pgsql-bugs@arkaria.postgresql.org; Sat, 07 Oct 2017 00:36:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e0d6W-0001Xj-L9 for pgsql-bugs@arkaria.postgresql.org; Sat, 07 Oct 2017 00:36:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e0d6W-0001XZ-6K for pgsql-bugs@postgresql.org; Sat, 07 Oct 2017 00:36:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e0d6O-00043Y-IV for pgsql-bugs@postgresql.org; Sat, 07 Oct 2017 00:36:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v970aKNG002715; Fri, 6 Oct 2017 20:36:20 -0400 From: Tom Lane To: Andres Freund cc: Lucas Fairchild-Madar , pgsql-bugs@postgresql.org Subject: Re: json(b)_array_elements use causes very large memory usage when also referencing entire json document In-reply-to: <20171007002116.2fqr6z26byhsjwoe@alap3.anarazel.de> References: <1546.1507314635@sss.pgh.pa.us> <2376.1507315734@sss.pgh.pa.us> <4514.1507318623@sss.pgh.pa.us> <20171007002116.2fqr6z26byhsjwoe@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Fri, 06 Oct 2017 17:21:16 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2713.1507336580.1@sss.pgh.pa.us> Date: Fri, 06 Oct 2017 20:36:20 -0400 Message-ID: <2714.1507336580@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Andres Freund 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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs