pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrei Lepikhov <lepihov@gmail.com>
To: Alexander Korotkov <aekorotkov@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alena Rybakina <a.rybakina@postgrespro.ru>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: Alexander Lakhin <exclusion@gmail.com>
Cc: Gregory Stark (as CFM) <stark.cfm@gmail.com>
Cc: Michał Kłeczek <michal@kleczek.org>
Cc: Dean Rasheed <dean.a.rasheed@gmail.com>
Subject: Re: Removing unneeded self joins
Date: Sun, 23 Feb 2025 23:12:36 +0100
Message-ID: <df21bd7e-5ec8-4e45-a339-b3a59ec48d1e@gmail.com> (raw)
In-Reply-To: <CAPpHfdt-F2CzQEEDZjhDB0pHMP-FdWt-jv6DVsO+5JZEGpTyTA@mail.gmail.com>
References: <64486b0b-0404-e39e-322d-0801154901f3@postgrespro.ru>
	<3622801.1715010885@sss.pgh.pa.us>
	<CAPpHfduRB9oW3YRDpvPGcDSAbH4iu0LSRhxpRRAzBh7euC9amQ@mail.gmail.com>
	<CAEZATCUeJ93gWCEzK1eRxyZakvv5PVG9LfF3PkSGMsNBC7h9kA@mail.gmail.com>
	<CAPpHfdsj1WdqoCg+g4oq1XQ_=KOj0U4pXqhauBc7e+0msHu66A@mail.gmail.com>
	<CAPpHfds16a7bjQHv-jCLMNzwdukJ_i3da2e0OJFB9L5rTCWEEg@mail.gmail.com>
	<ac7d7334-7ebb-4330-a894-12ba12ffa4ae@gmail.com>
	<CAPpHfdsuc524-BkXNZ+iz9dH=-KiU8qx9CSyE-Nip4Wjz5pGgg@mail.gmail.com>
	<ac34e44e-f8e1-4601-8bb8-fa5e65578832@gmail.com>
	<CAPpHfdvHzExyROoxvVQz6JR4tGVOjgNyHnu8xJmGcx-bMxWvqw@mail.gmail.com>
	<5934ce1e-be02-4640-904c-f7fec3962784@gmail.com>
	<CAPpHfdt9Z=iriS1Fj0Vyo41Z4cS+zUSZM8D3qXyw5LfHr_jVjA@mail.gmail.com>
	<CAPpHfdsFcde5VWCxSup7x_12ig6uynrFaOms62-M_c8DM-FTBQ@mail.gmail.com>
	<CAPpHfdseDr02BT+kFfW1ORWd0xnf9B=OUNmYkDxF2x-bE32UOw@mail.gmail.com>
	<914330.1740330169@sss.pgh.pa.us>
	<CAPpHfdt-F2CzQEEDZjhDB0pHMP-FdWt-jv6DVsO+5JZEGpTyTA@mail.gmail.com>

On 23/2/2025 22:15, Alexander Korotkov wrote:
> There is my attempt to implement this approach.  Getting rid of local
> variable (and computation of the same value other way) required to
> change arguments of remove_rel_from_eclass() as well.  I'm going to
> further polish this tomorrow.
I passed through the patch. It works correctly.

Multiple ifs in a single routine is not ideal. I have thought about it 
already, and it seems the remove_rel_from_query needs refactoring: when 
I first reused it for self-join removal, we didn't have the 'ojrelid' 
machinery, and it was implemented smoothly.
Right now, this code contains multiple places where we need to remove 
the outer join relid and separating the removal code for the baserel and 
outer join may simplify the logic and make it safer.
But the way to do it is not apparent now. May be if we implement a new 
technique of query tree reduction, the approach will become more evident.

-- 
regards, Andrei Lepikhov





view thread (247+ messages)  latest in thread

Message-ID: <df21bd7e-5ec8-4e45-a339-b3a59ec48d1e@gmail.com>
Permalink:  ../df21bd7e-5ec8-4e45-a339-b3a59ec48d1e@gmail.com/
Also on:    postgresql.org/message-id/df21bd7e-5ec8-4e45-a339-b3a59ec48d1e@gmail.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: lepihov@gmail.com, aekorotkov@gmail.com, tgl@sss.pgh.pa.us, a.rybakina@postgrespro.ru, pgsql-hackers@lists.postgresql.org, robertmhaas@gmail.com, guofenglinux@gmail.com, exclusion@gmail.com, stark.cfm@gmail.com, michal@kleczek.org, dean.a.rasheed@gmail.com
  Subject: Re: Removing unneeded self joins
  In-Reply-To: <df21bd7e-5ec8-4e45-a339-b3a59ec48d1e@gmail.com>

* 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