Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tK3zH-006dI3-Jc for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Dec 2024 23:13:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tK3zE-00HWz6-So for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Dec 2024 23:13:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tK3zE-00HWyy-IW for pgsql-hackers@lists.postgresql.org; Sat, 07 Dec 2024 23:13:21 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tK3zD-001ZYM-82 for pgsql-hackers@lists.postgresql.org; Sat, 07 Dec 2024 23:13:20 +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 4B7NDFoE3517445; Sat, 7 Dec 2024 18:13:15 -0500 From: Tom Lane To: Andres Freund cc: =?utf-8?B?0JjQu9GM0Y8g0JbQsNGA0LrQvtCy?= , pgsql-hackers@lists.postgresql.org Subject: Re: Do not scan index in right table if condition for left join evaluates to false using columns in left table In-reply-to: References: <3510224.1733609212@sss.pgh.pa.us> Comments: In-reply-to Andres Freund message dated "Sat, 07 Dec 2024 18:07:16 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3517443.1733613195.1@sss.pgh.pa.us> Date: Sat, 07 Dec 2024 18:13:15 -0500 Message-ID: <3517444.1733613195@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > On 2024-12-07 17:06:52 -0500, Tom Lane wrote: >> One could imagine that we split up the join filter conditions into >> "depends on RHS" and "doesn't depend on RHS" subsets, and make the >> nestloop plan node evaluate the latter set only once per LHS row, >> and then skip the inner-side scan when that condition fails. > As I wrote in my other email, I'm also somewhat dubious it's worth having > explicit code for this in nodeNestloop.c. Yeah. Your idea of pushing the "doesn't depend on RHS" subset into a one-time Result filter atop the RHS is interesting though. Then we don't need any new executor machinery, but we pay for that with a more complex planner patch. Not sure how hard that would be. regards, tom lane