Re: should we have a fast-path planning for OLTP starjoins? - Mailing list pgsql-hackers

From Robert Haas
Subject Re: should we have a fast-path planning for OLTP starjoins?
Date
Msg-id CA+Tgmoa1cJF_PGzNjZCr+c8xyv_Aund6F5qoeSuN4WHf539Y3g@mail.gmail.com
Whole thread Raw
In response to Re: should we have a fast-path planning for OLTP starjoins?  (Bruce Momjian <bruce@momjian.us>)
Responses Re: should we have a fast-path planning for OLTP starjoins?
Re: should we have a fast-path planning for OLTP starjoins?
List pgsql-hackers
On Sat, Dec 20, 2025 at 5:49 PM Bruce Momjian <bruce@momjian.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.

> In the group execution order we are considering:
>
> 1.  restriction joins
> 2.  neutral joins
> 3.  expansion joins
>
> do we generate only the cheapest path for each group or return multiple
> paths that can be considered by later group executions?  If not, if we
> join the same column in stages 1 & 2, would it make sense to move the
> stage 2 join into stage 1 so we can potentially use sort order
> (pathkeys) for both joins?  Similarly if we join the same column in
> stage 2 & 3 can we move the stage 2 join to stage 3?  I don't think it
> is worth moving stage 1 to 3 or 3 to 1 since it seems too risky.

I'm not sure this is what the patch is actually doing -- it's
definitely not what the current code is doing.

--
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: apply_scanjoin_target_to_paths and partitionwise join
Next
From: "zengman"
Date:
Subject: Re:cleanup: Split long Makefile lists across lines and sort them