Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oHI24-000626-7Q for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Jul 2022 04:55:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oHI22-0002oY-6e for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Jul 2022 04:55:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oHI21-0002oP-U5 for pgsql-hackers@lists.postgresql.org; Fri, 29 Jul 2022 04:55:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oHI1w-0002wz-19 for pgsql-hackers@postgresql.org; Fri, 29 Jul 2022 04:55:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 26T4tH423633495; Fri, 29 Jul 2022 00:55:17 -0400 From: Tom Lane To: Amit Langote cc: Robert Haas , Jacob Champion , Zhihong Yu , David Rowley , PostgreSQL-development Subject: Re: generic plans and "initial" pruning In-reply-to: References: <215356.1647286703@sss.pgh.pa.us> ! message dated "Fri, 29 Jul 2022 13:20:37 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3633493.1659070517.1@sss.pgh.pa.us> Date: Fri, 29 Jul 2022 00:55:17 -0400 Message-ID: <3633494.1659070517@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Amit Langote writes: > On Thu, Jul 28, 2022 at 1:27 AM Robert Haas wrote: >> I wonder whether it's really necessary to added the PartitionPruneInfo >> objects to a list in PlannerInfo first and then roll them up into >> PlannerGlobal later. I know we do that for range table entries, but >> I've never quite understood why we do it that way instead of creating >> a flat range table in PlannerGlobal from the start. And so by >> extension I wonder whether this table couldn't be flat from the start >> also. > Tom may want to correct me but my understanding of why the planner > waits till the end of planning to start populating the PlannerGlobal > range table is that it is not until then that we know which subqueries > will be scanned by the final plan tree, so also whose range table > entries will be included in the range table passed to the executor. It would not be profitable to flatten the range table before we've done remove_useless_joins. We'd end up with useless entries from subqueries that ultimately aren't there. We could perhaps do it after we finish that phase, but I don't really see the point: it wouldn't be better than what we do now, just the same work at a different time. regards, tom lane