Re: Removing unneeded self joins

From: "Andrey V(dot) Lepikhov" <a(dot)lepikhov(at)postgrespro(dot)ru>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: David Steele <david(at)pgmasters(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Removing unneeded self joins
Date: 2020-10-31 09:26:29
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thank you for this partial review, I included your changes:

On 9/23/20 9:23 AM, David Rowley wrote:
> On Fri, 3 Apr 2020 at 17:43, Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru> wrote:
> Doing thing the way I describe will allow you to get rid of all the
> UniqueRelInfo stuff.
Thanks for the review and sorry for the late reply.
I fixed small mistakes, mentioned in your letter.
Also I rewrote this patch at your suggestion [1].
Because of many changes, this patch can be viewed as a sketch.

To change self-join detection algorithm I used your delta patch from
[2]. I added in the split_selfjoin_quals routine complex expressions
handling for demonstration. But, it is not very useful with current
infrastructure, i think.

Also I implemented one additional way for self-join detection algorithm:
if the join target list isn't contained vars from inner relation, then
we can detect self-join with only quals like a1.x=a2.y if check
innerrel_is_unique is true.
Analysis of the target list is contained in the new routine -
tlist_contains_rel_exprs - rewritten version of the build_joinrel_tlist

Also changes of the join_is_removable() routine is removed from the
patch. I couldn't understand why it is needed here.

Note, this patch causes change of one join.sql regression test output.
It is not a bug, but maybe fixed.

Applied over commit 4a071afbd0.

> [1]

Andrey Lepikhov
Postgres Professional

Attachment Content-Type Size
v24-0001-Remove-self-joins.patch text/x-patch 65.9 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2020-10-31 10:58:18 Re: A new function to wait for the backend exit after termination
Previous Message Justin Pryzby 2020-10-31 06:31:17 CREATE INDEX CONCURRENTLY on partitioned index