Re: should we have a fast-path planning for OLTP starjoins?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Tomas Vondra <tomas(at)vondra(dot)me>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: should we have a fast-path planning for OLTP starjoins?
Date: 2025-12-24 18:16:41
Message-ID: 949756.1766600201@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Sat, Dec 20, 2025 at 5:49 PM Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>> It seems we have to identify these joins _before_ we actually start the
>> main optimizer. We can identify restriction joins since we see the
>> restriction in the query, and we can identify neutral joins because of
>> foreign keys. How do we identify expansion joins? Is it all the joins
>> which are not the previous types?

> We unfortunately have no way to identify these joins before we
> actually start the main optimizer; that's not how the code works. I'm
> not sure if there's a reasonable way to do better, because whether the
> join inflates or reduces the row count can't be known independently of
> the join order in general, even though in practice it often can.

I think the core idea of this proposal is to improve cases where
we *can* know that; where we can't, just do what we've always done.
Not handling every case isn't a fatal objection, as long as the
patch doesn't spend much time to discover that it can't help.

Having said that, I'm starting to wonder whether "do this stuff in a
separate pass before the main optimizer" is the wrong structural
decision. Should we be injecting the logic at some later point
where we've gathered more information? At least in principle,
we should be able to build all base-relation Paths before we start
to think about join order; would having those help?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2025-12-24 18:52:05 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Previous Message Bruce Momjian 2025-12-24 17:55:29 Re: should we have a fast-path planning for OLTP starjoins?