Use "unique keys" to enhance outer join removal

Started by Antonin Houskaalmost 2 years ago1 messages
Jump to latest
#1Antonin Houska
ah@cybertec.at

While the "unique keys" feature [1]/messages/by-id/7971.1713526758@antos -- Antonin Houska Web: https://www.cybertec-postgresql.com 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]/messages/by-id/7971.1713526758@antos -- Antonin Houska Web: https://www.cybertec-postgresql.com, 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]/messages/by-id/7971.1713526758@antos -- Antonin Houska Web: https://www.cybertec-postgresql.com.

[1]: /messages/by-id/7971.1713526758@antos -- Antonin Houska Web: https://www.cybertec-postgresql.com
--
Antonin Houska
Web: https://www.cybertec-postgresql.com

Attachments:

0001-Undo-comment-changes.patchtext/x-diffDownload+11-4
0002-Use-Unique-Keys-to-remove-an-useless-left-join.patchtext/x-diffDownload+73-36