pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thom Brown <thom@linux.com>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: remove_useless_joins vs. bug #19560
Date: Sun, 26 Jul 2026 13:33:26 -0400
Message-ID: <3304318.1785087206@sss.pgh.pa.us> (raw)
In-Reply-To: <CAA-aLv4UbdjHarp8zaK4PQjFHZVrt27hxmZqqBUn3yR_5CpgjQ@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>

Thom Brown <thom@linux.com> writes:
> Thanks. I've re-tested against these and I'm no longer able to crash it.

Thanks for testing!

> And it still reports the same previous planner regression, although
> thinks it may be considered acceptable. It also mentioned adding
> jointype assertions because the hoisting code doesn't have any.

Yeah, it occurred to me right after sending out the v3 patchset that
fixup_selfjoin_jointree should have an Assert that it doesn't hoist
anything above an outer join.  Revised 0004 attached has that, and
adds a test case based on this example.  0001-0003 still the same.

As for the performance issue, I attach an 0005 that changes the
self-join logic to perform as many removals as it can.  I don't
have a huge amount of faith in that, but I can't immediately see
any reason why it's not okay.  It seems almost certainly okay to
perform SJE within groups of rels with different common OIDs, and
even within a single group, an earlier removal doesn't look like
it'd trash anything we are looking at.  But it'd be worth running
a fuzzer to see if any cases turn up where the patchset fails or
gives different answers with/without 0005.

			regards, tom lane

#text/x-diff; name="v4-0001-Postpone-initialization-of-all_result_relids-leaf.patch" [v4-0001-Postpone-initialization-of-all_result_relids-leaf.patch] /home/tgl/pgsql/v4-0001-Postpone-initialization-of-all_result_relids-leaf.patch
#text/x-diff; name="v4-0002-Perform-join-removal-by-editing-the-query-s-joint.patch" [v4-0002-Perform-join-removal-by-editing-the-query-s-joint.patch] /home/tgl/pgsql/v4-0002-Perform-join-removal-by-editing-the-query-s-joint.patch
#text/x-diff; name="v4-0003-Remove-dead-code-that-s-no-longer-needed-for-join.patch" [v4-0003-Remove-dead-code-that-s-no-longer-needed-for-join.patch] /home/tgl/pgsql/v4-0003-Remove-dead-code-that-s-no-longer-needed-for-join.patch
#text/x-diff; name="v4-0004-Ensure-we-hoist-modified-quals-to-the-right-join-.patch" [v4-0004-Ensure-we-hoist-modified-quals-to-the-right-join-.patch] /home/tgl/pgsql/v4-0004-Ensure-we-hoist-modified-quals-to-the-right-join-.patch
#text/x-diff; name="v4-0005-Allow-remove_useless_self_joins-to-remove-multipl.patch" [v4-0005-Allow-remove_useless_self_joins-to-remove-multipl.patch] /home/tgl/pgsql/v4-0005-Allow-remove_useless_self_joins-to-remove-multipl.patch





view thread (74+ messages)  latest in thread

Message-ID: <3304318.1785087206@sss.pgh.pa.us>
Permalink:  ../3304318.1785087206@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3304318.1785087206@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, thom@linux.com, guofenglinux@gmail.com
  Subject: Re: remove_useless_joins vs. bug #19560
  In-Reply-To: <3304318.1785087206@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>

* 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