Re: Removing unneeded self joins

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru>, Richard Guo <guofenglinux(at)gmail(dot)com>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Alexander Lakhin <exclusion(at)gmail(dot)com>, "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, Michał Kłeczek <michal(at)kleczek(dot)org>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Subject: Re: Removing unneeded self joins
Date: 2025-06-26 06:54:55
Message-ID: b2136e2b-c668-45e2-932c-9fcd583114aa@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 26/6/2025 07:40, Michael Paquier wrote:
> Anyway, it seems to me that we may need to do something here before
> the release. Note that if the consensus is "you should update your
> module and not rely on the past behavior", I'm OK with that. I just
> wanted to raise the issue before this goes GA. And well, I have a
> pretty big pool of users that rely on this module, so..
Thanks for the report and detailed explanation!
Before diving into the pg_hint_plan code, I wonder why you don't have
similar issues with the remove_useless_joins. We intentionally designed
SJE coupled with the left-join removal feature to avoid such type of
complaints:

CREATE TABLE test (x integer PRIMARY KEY);
EXPLAIN (COSTS OFF)
SELECT t1.* FROM test t1 LEFT JOIN test t2 ON (t1.x=t2.x);

/*
QUERY PLAN
---------------------
Seq Scan on test t1
(1 row)
*/

It seems that this join removal is also beyond the pg_hint_plan control ...

--
regards, Andrei Lepikhov

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2025-06-26 06:56:08 PG18 protocol version
Previous Message Tatsuo Ishii 2025-06-26 06:47:00 Re: [PATCH] Proposal: Improvements to PDF stylesheet and table column widths