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.96) (envelope-from ) id 1wogrM-001CjE-0b for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Jul 2026 12:24:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wogrL-000eHC-0M for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Jul 2026 12:24:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wogrK-000eH4-2f for pgsql-hackers@lists.postgresql.org; Tue, 28 Jul 2026 12:24:34 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wogrH-00000000iKJ-1sF7 for pgsql-hackers@lists.postgresql.org; Tue, 28 Jul 2026 12:24:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 66SCOPN24154378; Tue, 28 Jul 2026 08:24:25 -0400 From: Tom Lane To: Tender Wang cc: Richard Guo , Thom Brown , Jacob Brazeal , pgsql-hackers@lists.postgresql.org Subject: Re: remove_useless_joins vs. bug #19560 In-reply-to: References: <1186816.1784573544@sss.pgh.pa.us> <2727652.1784997994@sss.pgh.pa.us> <2746010.1785014587@sss.pgh.pa.us> <2933135.1785032128@sss.pgh.pa.us> <3304318.1785087206@sss.pgh.pa.us> <3304418.1785087314@sss.pgh.pa.us> <3968565.1785170019@sss.pgh.pa.us> <3975112.1785176472@sss.pgh.pa.us> Comments: In-reply-to Tender Wang message dated "Tue, 28 Jul 2026 16:58:58 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4154376.1785241465.1@sss.pgh.pa.us> Date: Tue, 28 Jul 2026 08:24:25 -0400 Message-ID: <4154377.1785241465@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tender Wang writes: > I think this issue is still worth fixing. The discussion in [1] has > been inactive for about two months, so I wanted to ask whether you > intend to address it as part of the analyzejoins.c rewrite, or whether > it would be better for me to resume work on [1] once the rewrite has > been committed. I disagree. That's not a bug -- okay, it's a missed optimization for a small class of poorly-written queries -- and it's not specific to SJE either. I think far too much development effort has been spent on the point already. See my upthread reply to Richard [1]. (BTW, sitting here in the light of morning, a totally different approach occurs to me. The reason that the user-written IS NOT NULL is useless is that it's testing the result of a joined column, where the join operator is strict and the join isn't null-extending. I wonder if we could detect that and then throw away the upper IS NOT NULL, independently of any join-elimination strategy. I think there is precedent for this idea in the SQL standard's idea of known dependencies within queries. It might still not be worth the planner cycles, but ...) regards, tom lane [1] https://www.postgresql.org/message-id/3968565.1785170019%40sss.pgh.pa.us