Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1faO3z-0005gc-NV for pgsql-committers@arkaria.postgresql.org; Tue, 03 Jul 2018 16:21:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1faO3x-0003s1-QI for pgsql-committers@arkaria.postgresql.org; Tue, 03 Jul 2018 16:21:57 +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 1faO3x-0003ru-LS for pgsql-committers@lists.postgresql.org; Tue, 03 Jul 2018 16:21:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1faO3u-0008U2-7k for pgsql-committers@postgresql.org; Tue, 03 Jul 2018 16:21:57 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w63GLYud025551; Tue, 3 Jul 2018 12:21:35 -0400 From: Tom Lane To: Ashutosh Bapat cc: Amit Langote , David Rowley , Michael Paquier , Robert Haas , pgsql-committers Subject: Re: pgsql: Clarify use of temporary tables within partition trees In-reply-to: References: <20180702221650.GA2159@paquier.xyz> <20180703045502.GA26236@paquier.xyz> <20180703061119.GA11732@paquier.xyz> <5db5fe6e-4a73-6a24-09e4-060b9f132ea9@lab.ntt.co.jp> <20180703070551.GC11732@paquier.xyz> <79177436-0b62-ee4f-2526-f58db4a45df0@lab.ntt.co.jp> Comments: In-reply-to Ashutosh Bapat message dated "Tue, 03 Jul 2018 17:45:46 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <65155.1530634894.1@sss.pgh.pa.us> Date: Tue, 03 Jul 2018 12:21:34 -0400 Message-ID: <65156.1530634894@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ashutosh Bapat writes: > On Tue, Jul 3, 2018 at 3:20 PM, Amit Langote > wrote: >> Maybe because that's what's done for the root parent in a plain >> inheritance hierarchy, which is always a plain table. In that case, one >> RTE is for its role as the parent (with rte->inh = true) and another is >> for its role as a child (with rte->inh = false). The former is processed >> as an append rel and the latter as a plain rel that will get assigned scan >> paths such as SeqScan, etc. > Yes that's true. Yes, that's exactly why there are two RTEs for the parent table in normal inheritance cases. I concur with the idea that it shouldn't be necessary to create a child RTE for a partitioning parent table --- we should really only need the appendrel RTE plus RTEs for tables that will be scanned. However, it's not clear to me that this is a trivial change for multilevel partitioning cases. Do we need RTEs for the intermediate nonleaf levels? In the abstract, the planner and executor might not need them. But the code that deals with partitioning constraint management might expect them to exist. Another point is that executor-start-time privilege checking is driven off the RTE list, so we need an RTE for any table that requires priv checks, so we might need RTEs for intermediate levels just for that. Also, IIRC, the planner sets up the near-duplicate RTEs for inheritance cases so that only one of them is privilege-checked. Be careful that you don't end up with zero privilege checks on the partition root :-( regards, tom lane