Rowley: What’s new in the Postgres 16 query planner / optimizer

Post Syndicated from corbet original https://lwn.net/Articles/961545/

David Rowley looks
deeply
into the improvements coming to the query planner in
PostgreSQL 16.

For a long time now, PostgreSQL has been able to remove a LEFT JOIN
where no column from the left joined table was required in the
query and the join could not possibly duplicate any rows.

However, in versions prior to PostgreSQL 16, there was no support
for left join removals on partitioned tables. Why? Because the
proofs that the planner uses to determine if there’s any
possibility any inner-side row could duplicate any outer-side row
were not present for partitioned tables.

The PostgreSQL 16 query planner now allows the LEFT JOIN removal
optimization with partitioned tables.