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 1lhKeb-0003sy-RY for pgsql-hackers@arkaria.postgresql.org; Thu, 13 May 2021 23:22:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lhKeZ-0002s3-M8 for pgsql-hackers@arkaria.postgresql.org; Thu, 13 May 2021 23:22:03 +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 1lhKeZ-0002rv-Ek for pgsql-hackers@lists.postgresql.org; Thu, 13 May 2021 23:22:03 +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 1lhKeV-0004p9-GG for pgsql-hackers@postgresql.org; Thu, 13 May 2021 23:22:02 +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 14DNLvHN1727508; Thu, 13 May 2021 19:21:57 -0400 From: Tom Lane To: Dmitry Astapov cc: PostgreSQL-development Subject: Re: Condition pushdown: why (=) is pushed down into join, but BETWEEN or >= is not? In-reply-to: References: <1099349.1620834846@sss.pgh.pa.us> Comments: In-reply-to Dmitry Astapov message dated "Wed, 12 May 2021 18:56:00 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1727506.1620948117.1@sss.pgh.pa.us> Date: Thu, 13 May 2021 19:21:57 -0400 Message-ID: <1727507.1620948117@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dmitry Astapov writes: > Am I right in thinking that elimination the join condition is actually > quite important part of the process? > Could it possibly be the main reason for =ANY/(x IN (..)) not to be > optimized the same way? Yup. > Is it still hard when one thinks about =ANY or (column in (val1, val2, > val3, ...)) as well? Yeah. For instance, if you have WHERE a = b AND a IN (1,2,3) then yes, you could deduce "b IN (1,2,3)", but this would not give you license to drop the "a = b" condition. So now you have to figure out what the selectivity of that is after the application of the partially redundant IN clauses. I recall somebody (David Rowley, maybe? Too lazy to check archives.) working on this idea awhile ago, but he didn't get to the point of a committable patch. regards, tom lane