Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8GRm-00086W-1e for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Apr 2018 02:34:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f8GRk-00033w-Gq for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Apr 2018 02:34:16 +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.89) (envelope-from ) id 1f8GRk-00033m-9R for pgsql-hackers@lists.postgresql.org; Tue, 17 Apr 2018 02:34:16 +0000 Received: from [66.111.4.221] (helo=new1-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8GRc-0006s3-Sr for pgsql-hackers@postgresql.org; Tue, 17 Apr 2018 02:34:15 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 5C7E71295; Mon, 16 Apr 2018 22:33:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 16 Apr 2018 22:33:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=grvz3KgwqKHhfYRFg LBBRsbOYCDyhLg7ncGU8gLz6mU=; b=S2rc0fFZ+FM8shvILL/mdl5X98HWTzuNE JpCurwd3BnGF8dm00wxufWnrZRYJZ0leLeajmCH9rIXElOxUM0wSmDu5XJgwO/6Z VWFtwdFJblTQ3ObeTaQyNJ6OvCT6gPpU2nzWufWT3bg3HnvHG3rM7/OpraxdGEyo 9F9NtMI7UU1K7NHvUac4faLKJm7KAitvAFc7KYjaxQ5PkoefpS5y55AUHF/zxD2T ONbHPggnZyGnZDEM22tRVpe7hb7hNe/qCyEdbH/NfciDG75cW7Bf8mgDnXyMAX+m TKKtO6ucsileZMBTNezJZy2WNzDBoNqWDXgO9jSh5StxYp/DsIsxg== X-ME-Sender: Received: from alvin.alvh.no-ip.org (unknown [179.56.51.182]) by mail.messagingengine.com (Postfix) with ESMTPA id 577EFE443C; Mon, 16 Apr 2018 22:33:46 -0400 (EDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 69FE0538; Mon, 16 Apr 2018 23:33:43 -0300 (-03) Date: Mon, 16 Apr 2018 23:33:43 -0300 From: Alvaro Herrera To: David Rowley Cc: Robert Haas , Amit Langote , Amit Langote , Jesper Pedersen , Rajkumar Raghuwanshi , Beena Emerson , amul sul , "pgsql-hackers@postgresql.org" , Dilip Kumar Subject: Re: [HACKERS] Runtime Partition Pruning Message-ID: <20180417023343.6fg3i7m534lstxom@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.221 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Rowley wrote: > For a while, during my review of the faster partition pruning patch I > was asking Amit to add pfree() calls in various places for this exact > reason, but in the end, I gave up and decided it was easier to just > create a new memory context to call the planner function from. I've > now forgotten the exact reason why I finally decided it was too much > trouble. The pruning code now works using your step logic so perhaps > that reason no longer applies, although, on a quick scan of the > pruning code now, it seems to require that get_matching_partitions > performs a deep pfree of each PruneStepResult. However, there is still > partkey_datum_from_expr which performs ExecInitExpr, although perhaps > that can just be done once, and the result stashed in the > PartitionPruneContext. I think trying to replace a well-placed MemoryContextReset (or Delete) with a bunch of individual pfrees is pointless. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services