Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1lip-0005gZ-9Q for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Nov 2016 02:56:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1c1lio-0007aL-T1 for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Nov 2016 02:56:14 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1c1lio-0007aE-9p for pgsql-hackers@postgresql.org; Wed, 02 Nov 2016 02:56:14 +0000 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1lik-0000YU-9C for pgsql-hackers@postgresql.org; Wed, 02 Nov 2016 02:56:12 +0000 Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id uA22u5UR005711; Wed, 2 Nov 2016 11:56:05 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id DC46F5F594; Wed, 2 Nov 2016 11:56:04 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id C1EB35F593; Wed, 2 Nov 2016 11:56:04 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTP id 9A799400368; Wed, 2 Nov 2016 11:56:04 +0900 (JST) Subject: Re: Declarative partitioning - another take References: <169708f6-6e5a-18d1-707b-1b323e4a6baf@lab.ntt.co.jp> <4f7108cb-7185-e956-d746-ad756b52431a@lab.ntt.co.jp> <28ee345c-1278-700e-39a7-36a71f9a3b43@lab.ntt.co.jp> <7aa6a14d-9476-afd7-2c09-6a016eb8c12b@lab.ntt.co.jp> <377bc541-2108-4500-4b87-1b5936553555@lab.ntt.co.jp> <9ac4ba01-35cf-658b-5a57-c516c4ccedff@lab.ntt.co.jp> From: Amit Langote Message-ID: <0a299fbf-e5a1-dc3d-eb5e-11d3601eac16@lab.ntt.co.jp> Date: Wed, 2 Nov 2016 11:55:51 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit To: Robert Haas Cc: Amit Langote , Rajkumar Raghuwanshi , Ashutosh Bapat , Pg Hackers X-TM-AS-MML: disable X-Pg-Spam-Score: -5.1 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2016/11/02 2:53, Robert Haas wrote: > On Fri, Oct 28, 2016 at 3:53 AM, Amit Langote > wrote: >> [ new patches ] > > Reviewing 0005: > > Your proposed commit messages says this: > >> If relation is the target table (UPDATE and DELETE), flattening is >> done regardless (scared to modify inheritance_planner() yet). I should have explained my thinking behind why I ended up not handling the result relation case: While set_append_rel_size() can be safely invoked recursively on the roots of partition sub-trees, I was not quite sure if inheritance_planner() is amenable to such recursive invocation. While the former is relatively straightforward baserel processing, the latter is not-so-straightforward transformation of the whole query for every target child relation of the target parent. > In the immortal words of Frank Herbert: “I must not fear. Fear is the > mind-killer. Fear is the little-death that brings total obliteration. > I will face my fear. I will permit it to pass over me and through me. > And when it has gone past I will turn the inner eye to see its path. > Where the fear has gone there will be nothing. Only I will remain.” > > In other words, I'm not going to accept fear as a justification for > randomly-excluding the target-table case from this code. If there's > an actual reason not to do this in that case or some other case, then > let's document that reason. But weird warts in the code that are > justified only by nameless anxiety are not good. Perhaps the above comment expands a little on the actual reason. Though I guess it still amounts to giving up on doing a full analysis of whether recursive processing within inheritance_planner() is feasible. I think we could just skip this patch as long as a full investigation into inheritance_planner() issues is not done. It's possible that there might be other places in the planner code which are not amenable to the proposed multi-level AppendRelInfos. Ashutosh had reported one [1], wherein lateral joins wouldn't work with multi-level partitioned table owing to the multi-level AppendRelInfos (the patch contains a hunk to address that). > Of course, the prior question is whether we should EVER be doing this. > I realize that something like this MAY be needed for partition-wise > join, but the mission of this patch is not to implement partition-wise > join. Does anything in this patch series really require this? If so, > what? If not, how about we leave it out and refactor it when that > change is really needed for something? Nothing *requires* it as such. One benefit I see is that exclusion of the root of some partition sub-tree means the whole sub-tree is excluded in one go. Currently, because of the flattening, every relation in that sub-tree would be excluded separately, needlessly repeating the expensive constraint exclusion proof. But I guess that's just an optimization. Thanks, Amit [1] https://www.postgresql.org/message-id/CAFjFpReZF34MDbY95xoATi0xVj2mAry4-LHBWVBayOc8gj%3Diqg%40mail.gmail.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers