Re: Removing unneeded self joins

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Richard Guo <guofenglinux(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: 2024-12-23 08:25:32
Message-ID: ac7d7334-7ebb-4330-a894-12ba12ffa4ae@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/9/24 13:03, Alexander Korotkov wrote:
> On Sat, Jul 20, 2024 at 2:38 PM Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:
> We may decide to generate not just a walker but most of the logic in
> remove_self_join_rel(). This is probably possible by injecting way
> more meta-information into definitions of structures. That isn't
> going to be simpler than the current approach. But it is probably
> less error-prone: one could realize that if you add a new field to the
> structure, it should have a similar pg_node_attr() as surroundings.
> But I am afraid that if we go this way, we may end up with an awkward
> heap of pg_node_attr() to generate the functionality of
> remove_self_join_rel(). Should we better add comments to PlannerInfo
> and other relevant structures saying: if you're going to modify this,
> consider how that affects remove_self_join_rel()?
>
> Any thoughts?

Observing positive cases caused by the SJE feature, I resumed the work
and, following Alexander's suggestion, added developer comments on
checking remove_self_join_rel in case of the PlannerInfo changes.

I see now that it helps apply after pull-up transformations and,
sometimes, because of clauses derived from EquivalenceClasses (see the
patch comment for examples). So, it is not only about dumb ORM-generated
queries.

Also, multiple code changes since the v7 version caused corresponding
changes in the SJE code on rebase. So, the new version provided in the
attachment needs a fresh review.

--
regards, Andrei Lepikhov

Attachment Content-Type Size
v8-0001-Remove-useless-self-joins.patch text/x-patch 128.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message 2024-12-23 09:12:12 Re: Re: transaction lost when delete clog file after normal shutdown
Previous Message David G. Johnston 2024-12-23 08:17:35 Re: Repeatable read transaction doesn't see dropped table