Use "unique keys" to enhance outer join removal

From: Antonin Houska <ah(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Use "unique keys" to enhance outer join removal
Date: 2024-04-29 08:10:36
Message-ID: 32781.1714378236@antos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While the "unique keys" feature [1] is still under development, I'm thinking
how it could be used to enhance the removal of useless outer joins. Is
something really bad about the 0002 patch attached?

I recognize it may be weird that a join relation possibly produces non-join
paths (e.g. SeqScan), but right now don't have better idea where the new code
should appear. I considered planning the subqueries before the existing call
of remove_useless_joins(), to make the unique keys available earlier. However
it seems that more items can be added to 'baserestrictinfo' of the subquery
relation after that. Thus by planning the subquery too early we could miss
some opportunities to push clauses down to the subquery.

Please note that this patch depends on [1], which enhances
rel_is_distinct_for() and thus makes join_is_removable() a bit smareter. Also
note that 0001 is actually a minor fix to [1].

[1] https://www.postgresql.org/message-id/7971.1713526758%40antos
--
Antonin Houska
Web: https://www.cybertec-postgresql.com

Attachment Content-Type Size
0001-Undo-comment-changes.patch text/x-diff 2.7 KB
0002-Use-Unique-Keys-to-remove-an-useless-left-join.patch text/x-diff 9.1 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-04-29 08:23:53 Virtual generated columns
Previous Message Kashif Zeeshan 2024-04-29 07:18:32 Re: small documentation fixes related to collations/ICU