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 1fSOJ4-0007CA-BE for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Jun 2018 15:00:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fSOJ2-0004fR-Sq for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Jun 2018 15:00:28 +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.89) (envelope-from ) id 1fSOJ2-0004e5-HL for pgsql-hackers@lists.postgresql.org; Mon, 11 Jun 2018 15:00:28 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fSOIv-0003yJ-MI for pgsql-hackers@lists.postgresql.org; Mon, 11 Jun 2018 15:00:27 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w5BF0ECN001926; Mon, 11 Jun 2018 11:00:14 -0400 From: Tom Lane To: David Rowley cc: Amit Langote , Dmitry Dolgov <9erthalion6@gmail.com>, Jeff Janes , Ashutosh Bapat , Pavel Stehule , PostgreSQL Hackers Subject: Re: why partition pruning doesn't work? In-reply-to: References: <7142.1527868419@sss.pgh.pa.us> <1111.1527977170@sss.pgh.pa.us> <10432.1528045900@sss.pgh.pa.us> <569483c5-a273-6537-1b5d-7a271ce439fb@lab.ntt.co.jp> <22805.1528386192@sss.pgh.pa.us> <21787.1528428171@sss.pgh.pa.us> <12624.1528578026@! sss.pgh.pa.us> <26279.1528670981@sss.pgh.pa.us> <556.1528727192@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Tue, 12 Jun 2018 02:40:25 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1924.1528729214.1@sss.pgh.pa.us> Date: Mon, 11 Jun 2018 11:00:14 -0400 Message-ID: <1925.1528729214@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Rowley writes: > On 12 June 2018 at 02:26, Tom Lane wrote: >>> ... I'd previously tried having NULL subnodes in >>> the Append and I thought it required too much hacking work in >>> explain.c, >> No, that was pretty much exactly what I was envisioning. > What you're proposing exchanges logic that fits neatly into one > function for special logic that will be scattered all over explain.c. > I really don't think that's the better of the two evils. As far as I can see, it'd involve about three or four lines' worth of rewrite in one place-you-already-made-quite-ugly in explain.c, and an added if-test in planstate_walk_members, and that'd be it. That seems like a pretty cheap price for being able to vastly simplify the invariants for the pruning functions. In fact, I doubt you'd even need two of them anymore; just one with a bool flag for can-use-exec-params. > I'd rather just see my last patch applied which simplifies the re-map > code by removing the 2nd loop. Actually, even updating the > present_parts to remove the unneeded subpartitioned table indexes is > optional. We' just need to give up on the elog(ERROR, "partition > missing from subplans"); error and assume that case is fine. The fact that you added that loop and only later decided it was unnecessary seems to me to support my point pretty strongly: that code is overcomplicated. regards, tom lane