Re: When can joins be avoided?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stefan Fehrenbach <stefan(dot)fehrenbach(at)gmail(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: When can joins be avoided?
Date: 2022-11-17 14:49:20
Message-ID: 1826810.1668696560@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Stefan Fehrenbach <stefan(dot)fehrenbach(at)gmail(dot)com> writes:
> I'm interested in the rules that Postgres uses to avoid joins. Are
> these documented somewhere? If I had to look at the source code, where
> would I start?

src/backend/optimizer/plan/analyzejoins.c

> They don't seem to match my intuition about which joins
> could be avoided.

I believe only left joins to single tables can be elided ATM.
It's too hard to prove uniqueness of the join key in more-
complicated cases.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Luca Ferrari 2022-11-18 12:15:23 why choosing an hash index instead of the btree version even if the cost is lower?
Previous Message Stefan Fehrenbach 2022-11-16 10:39:13 When can joins be avoided?