Waiting for Postgres 17: Better Query Plans for Materialized CTE Scans

Опубликовано: 11 Июль 2026
на канале: pganalyze
747
21

Find the article on our blog here:
https://pganalyze.com/blog/5mins-post...

In E118 of "5mins of Postgres" we discuss two changes in the upcoming Postgres 17 release that improve query plans for queries that involve CTEs. This can improve query plans where you would see an explicit CTE scan, due to use of the MATERIALIZED keyword, or because Postgres wasn't able to pull up a query to the upper plan level.

Learn more about pganalyze:
https://pganalyze.com
https://pganalyze.com/newsletter
  / pganalyze  

Check out the pganalyze library for eBooks, webinars, and more:
https://pganalyze.com/resources

📑 What we have discussed in this episode of 5mins of Postgres:

Extract column statistics from CTE references, if possible - Postgres commit by Tom Lane, co-authored by Jian Guo
https://git.postgresql.org/gitweb/?p=...

Wrong rows estimations with joins of CTEs slows queries by more than factor 500 - Mailinglist thread by Hans Buschmann on pgsql-hackers
https://www.postgresql.org/message-id...

BUG #18466: Wrong row estimate for nested loop - Mailinglist thread by Yan Wu on pgsql-bugs
https://www.postgresql.org/message-id...

Propagate pathkeys from CTEs up to the outer query - Postgres commit by Tom Lane, authored by Richard Guo
https://git.postgresql.org/gitweb/?p=...

Propagate pathkeys from CTEs up to the outer query - Mailinglist thread by Richard Guo on pgsql-hackers
https://www.postgresql.org/message-id...

What are the "tenk" and "onek" tables in the Postgres docs? - 5mins of Postgres E108 transcript
https://pganalyze.com/blog/5mins-post...

#postgres #postgresql #queryoptimization