Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gj5Yq-0007KM-Fk for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Jan 2019 16:58:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gj5Yp-0004pD-5L for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Jan 2019 16:58:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gj5Yo-0004nx-Rt for pgsql-bugs@lists.postgresql.org; Mon, 14 Jan 2019 16:58:03 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gj5Ym-0006xO-Hx for pgsql-bugs@lists.postgresql.org; Mon, 14 Jan 2019 16:58:01 +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 x0EGvtkZ027650; Mon, 14 Jan 2019 11:57:55 -0500 From: Tom Lane To: Andres Freund cc: pgsql-bugs@lists.postgresql.org, amdmi3@amdmi3.ru Subject: Re: BUG #15592: Memory overuse with subquery containing unnest() and set operations (11.x regression) In-reply-to: <27372.1547484627@sss.pgh.pa.us> References: <15592-cc5729f9ba02e31c@postgresql.org> <26375.1547483080@sss.pgh.pa.us> <3935CFAF-8FD4-459E-B13F-67DFEE852028@anarazel.de> <27372.1547484627@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 14 Jan 2019 11:50:27 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27648.1547485075.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 14 Jan 2019 11:57:55 -0500 Message-ID: <27649.1547485075@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > Andres Freund writes: >> Think I know where the problem is - let me have a coffee and check? I t= hink I might have a good lying around... > I had just determined that the extra context was added by bf6c614a2, The short answer here is that this addition to BuildTupleHashTable: hashtable->exprcontext =3D CreateExprContext(parent->state); allocates memory that is not freed by freeing the hashtable's tablecxt, breaking the API for grouping hashtables. Why does a hashtable need its own exprcontext now when it didn't before? regards, tom lane