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 1k1JcM-0001To-ES for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Jul 2020 01:13:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k1JcL-0002Lk-Do for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Jul 2020 01:13:49 +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 1k1JcL-0002LP-7b for pgsql-bugs@lists.postgresql.org; Fri, 31 Jul 2020 01:13:49 +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 1k1JcJ-00050z-8l for pgsql-bugs@lists.postgresql.org; Fri, 31 Jul 2020 01:13:48 +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 06V1DjWv1659524; Thu, 30 Jul 2020 21:13:45 -0400 From: Tom Lane To: David Rowley cc: mba.ogolny@gmail.com, PostgreSQL mailing lists Subject: Re: BUG #16558: `AND FALSE` increases planning time of query on 2 tables with 1000 partitions to more than 7 seconds In-reply-to: References: <16558-33763467d2edd1e9@postgresql.org> <1195168.1595950376@sss.pgh.pa.us> <1658306.1596156417@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Fri, 31 Jul 2020 12:53:46 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1659522.1596158025.1@sss.pgh.pa.us> Date: Thu, 30 Jul 2020 21:13:45 -0400 Message-ID: <1659523.1596158025@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Rowley writes: > hmm ok. FWIW, I did have in mind that the FALSE had been constant > folded from something more complex. Hm. Maybe that's a legitimate argument, not sure. But I'd still rather find someplace that's less critical performance-wise if we're going to try to hack up this case. I also wonder about cases like select * from (t1 join t2 on false) join t3 on t1.x=t3.y; If we were taking this seriously, it'd be nice to deduce that (1) the t1/t2 join is empty and (2) therefore so is the join to t3, so (3) we need not build paths for any of these base rels. I think the syntactically-driven method you're proposing would not catch that, which'd be problematic if t3 is the giant partitioned rel. [ wanders away wondering if reduce_outer_joins could be taught to do this... ] regards, tom lane