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 1hGE7n-0007F3-HT for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Apr 2019 02:47:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hGE7m-0005We-9l for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Apr 2019 02:47:06 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGE7m-0005WG-0i for pgsql-hackers@lists.postgresql.org; Tue, 16 Apr 2019 02:47:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGE7i-0008Gk-I7 for pgsql-hackers@lists.postgresql.org; Tue, 16 Apr 2019 02:47:05 +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 x3G2kubX000367; Mon, 15 Apr 2019 22:46:56 -0400 From: Tom Lane To: Andres Freund cc: pgsql-hackers@lists.postgresql.org Subject: ExecForceStoreMinimalTuple leaks memory like there's no tomorrow MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <365.1555382816.1@sss.pgh.pa.us> Date: Mon, 15 Apr 2019 22:46:56 -0400 Message-ID: <366.1555382816@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Using HEAD, create table t1 as select generate_series(1,40000000) id; vacuum analyze t1; explain select * from t1, t1 t1b where t1.id = t1b.id; -- should indicate a hash join explain analyze select * from t1, t1 t1b where t1.id = t1b.id; ... watch the process's memory consumption bloat. (It runs for awhile before that starts to happen, but eventually it goes to a couple of GB.) It looks to me like the problem is that ExecHashJoinGetSavedTuple calls ExecForceStoreMinimalTuple with shouldFree = true, and ExecForceStoreMinimalTuple's second code branch simply ignores the requirement to free the supplied tuple. regards, tom lane