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 1gj5H3-0006LI-Hk for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Jan 2019 16:39:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gj5H1-0002Ts-8Z for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Jan 2019 16:39:39 +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 1gj5Gz-0002Py-6o for pgsql-bugs@lists.postgresql.org; Mon, 14 Jan 2019 16:39:39 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gj5Gv-0002aE-3U for pgsql-bugs@lists.postgresql.org; Mon, 14 Jan 2019 16:39:36 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 990931C35; Mon, 14 Jan 2019 11:39:28 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 14 Jan 2019 11:39:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:in-reply-to:references:mime-version:content-type :content-transfer-encoding:subject:to:from:message-id; s=fm3; bh=AxPODKHrEai2vlZnxVhoELE909Ivja0tmBLM3W9aQWk=; b=Z5B2hdazNNvI LiiEaSfCDo1U6rjjwlRU8VnBJrxIGxzvQ6lZ4yf2V+/0q1+kkKnseD/e2qtU90lo FyO6JLkyqS9Dsw+BfFlBJkeoZenCBQ1pwCn3LxqWAYXGrptzCrF8zlsdM97IclZP FlTjkI4j2hnycIQJlnjsqNj3YRoIzFWISVSnHvAPyEQndF8HurXNWYNVCoIIebhQ 34l8H9P8GQnA+Bc2BgFxLB+463tNuLUT7BwaEhKxhK8ERUmY6YHsnUwyWu7wWhcc iSvdEhii8iUKcGSBfXAI79xBs2OUfP4ejpAj0H/mTHRvJwUahz0CeFWbBILY2YCo OkdMnCM32g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=AxPODKHrEai2vlZnxVhoELE909Ivja0tmBLM3W9aQ Wk=; b=ptd8HI+4xZfzfI3nfAEJ7vvdp70YJ3vZyvfdKhzewRi4ugjTUnOLT3vKL quXJ6xP4nMsML/A9t33YHNt1oVXkwhAIrI1+vt7MvY1gmpsymgpwR4oqyU7n39PW EkQmBycEpRynM+R1lBV38Ah8t4fc+BapzFseSGbfVVH6lSeufisia3VTk6e/RVnG oP8Kq1S11+bVJ42mBGouNkyHt1zjNa3GRT/f84ffnucIlU2fdAlpwVR/1A3UObCG iFlGeZEVTBo/vBj6FCDGK258NqnvsVf6IFE+EYV0uTjRvfjBBYZePybHL/axHwsZ 63FrlN98ODJZo0YzXHbe+j9bL5ECQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrgedugdelvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucenucfjughrpefffggjfhggtgfguffvhffksehtqhhmtddtreejnecuhfhrohhmpe etnhgurhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeen ucfkphepleekrddvuddtrddugedtrddujedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from android-8e4800d17a48919b.lan (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id 235BF100B8; Mon, 14 Jan 2019 11:39:27 -0500 (EST) Date: Mon, 14 Jan 2019 08:39:21 -0800 User-Agent: K-9 Mail for Android In-Reply-To: <26375.1547483080@sss.pgh.pa.us> References: <15592-cc5729f9ba02e31c@postgresql.org> <26375.1547483080@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: BUG #15592: Memory overuse with subquery containing unnest() and set operations (11.x regression) To: pgsql-bugs@lists.postgresql.org,Tom Lane ,amdmi3@amdmi3.ru From: Andres Freund Message-ID: <3935CFAF-8FD4-459E-B13F-67DFEE852028@anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On January 14, 2019 8:24:40 AM PST, Tom Lane wro= te: >=3D?utf-8?q?PG_Bug_reporting_form?=3D writes: >> After upgrading from PostgreSQL 10=2Ex to 11=2Ex this query began to ea= t >> inadequate amounts of memory (several gigabytes per hundred thousands >rows)=2E >> I've narrowed it down to this simple case which demonstrates the >problem: > >> CREATE TABLE test AS >> SELECT generate_series(1,500000) AS id, '{a,b}'::text[] AS first, >> '{a}'::text[] AS second; > >> SELECT DISTINCT EXISTS(SELECT unnest(first) INTERSECT SELECT >unnest(second)) >> FROM test; > >Ugh=2E Something is creating ExprContexts and not freeing them --- a >memory >context dump taken at ExecutorEnd shows > >ExecutorState: 100663296 total in 22 blocks; 4625424 free (19 chunks); >96037872 used > ExprContext: 8192 total in 1 blocks; 7936 free (0 chunks); 256 used > ExprContext: 8192 total in 1 blocks; 7936 free (0 chunks); 256 used > ExprContext: 8192 total in 1 blocks; 7936 free (0 chunks); 256 used > =2E=2E=2E >499916 more child contexts containing 4095311872 total in 499916 >blocks; 3967322616 free (1 chunks); 127989256 used > >Not sure where the problem is, yet, but for sure this is a bug=2E >Thanks for the report! Think I know where the problem is - let me have a coffee and check? I thin= k I might have a good lying around=2E=2E=2E --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E