pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tender Wang <tndrwang@gmail.com>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: Thom Brown <thom@linux.com>
Cc: Jacob Brazeal <jacob.brazeal@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: remove_useless_joins vs. bug #19560
Date: Tue, 28 Jul 2026 08:24:25 -0400
Message-ID: <4154377.1785241465@sss.pgh.pa.us> (raw)
In-Reply-To: <CAHewXN=uH+MmyRc3E0sCG1Ri_WGA4JeWHwntoUA+QD5rsVS=EQ@mail.gmail.com>
References: <1186816.1784573544@sss.pgh.pa.us>
	<CAMbWs49s+AdZgvrxm3bxqEWGKeFcK=r41TpfT+x+wzucVV+ORA@mail.gmail.com>
	<2727652.1784997994@sss.pgh.pa.us>
	<CAA-aLv7GGm3OwWOAGou0k-j5jyjSyOMqVc3-GxxO0NjjX+vDmg@mail.gmail.com>
	<2746010.1785014587@sss.pgh.pa.us>
	<2933135.1785032128@sss.pgh.pa.us>
	<CAA-aLv4UbdjHarp8zaK4PQjFHZVrt27hxmZqqBUn3yR_5CpgjQ@mail.gmail.com>
	<3304318.1785087206@sss.pgh.pa.us>
	<3304418.1785087314@sss.pgh.pa.us>
	<CAMbWs4_oMOZkKJF77TGwBsiN1vaKS568rxhE0Adzuwhrs6GLnQ@mail.gmail.com>
	<3968565.1785170019@sss.pgh.pa.us>
	<3975112.1785176472@sss.pgh.pa.us>
	<CAHewXN=uH+MmyRc3E0sCG1Ri_WGA4JeWHwntoUA+QD5rsVS=EQ@mail.gmail.com>

Tender Wang <tndrwang@gmail.com> 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






view thread (74+ messages)  latest in thread

Message-ID: <4154377.1785241465@sss.pgh.pa.us>
Permalink:  ../4154377.1785241465@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4154377.1785241465@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tndrwang@gmail.com, guofenglinux@gmail.com, thom@linux.com, jacob.brazeal@gmail.com
  Subject: Re: remove_useless_joins vs. bug #19560
  In-Reply-To: <4154377.1785241465@sss.pgh.pa.us>
  References: <1186816.1784573544@sss.pgh.pa.us> <CAMbWs49s+AdZgvrxm3bxqEWGKeFcK=r41TpfT+x+wzucVV+ORA@mail.gmail.com> <2727652.1784997994@sss.pgh.pa.us> <CAA-aLv7GGm3OwWOAGou0k-j5jyjSyOMqVc3-GxxO0NjjX+vDmg@mail.gmail.com> <2746010.1785014587@sss.pgh.pa.us> <2933135.1785032128@sss.pgh.pa.us> <CAA-aLv4UbdjHarp8zaK4PQjFHZVrt27hxmZqqBUn3yR_5CpgjQ@mail.gmail.com> <3304318.1785087206@sss.pgh.pa.us> <3304418.1785087314@sss.pgh.pa.us> <CAMbWs4_oMOZkKJF77TGwBsiN1vaKS568rxhE0Adzuwhrs6GLnQ@mail.gmail.com> <3968565.1785170019@sss.pgh.pa.us> <3975112.1785176472@sss.pgh.pa.us> <CAHewXN=uH+MmyRc3E0sCG1Ri_WGA4JeWHwntoUA+QD5rsVS=EQ@mail.gmail.com> <4154377.1785241465@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox