We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Waiting for Postgres 17: Better Query Plans for Materialized CTE Scans
Summary
Description
*Find the article on our blog here:*
https://pganalyze.com/blog/5mins-postgres-17-materialized-cte-scans
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/newsletter
https://www.linkedin.com/company/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*
*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/flat/4504e67078d648cdac3651b2960da6e7%40nidsa.net
*BUG #18466: Wrong row estimate for nested loop - Mailinglist thread by Yan Wu on pgsql-bugs*
https://www.postgresql.org/message-id/flat/18466-1d296028273322e2%40postgresql.org
*Propagate pathkeys from CTEs up to the outer query - Postgres commit by Tom Lane, authored by Richard Guo*
*Propagate pathkeys from CTEs up to the outer query - Mailinglist thread by Richard Guo on pgsql-hackers*
*What are the "tenk" and "onek" tables in the Postgres docs? - 5mins of Postgres E108 transcript*
#postgres #postgresql #queryoptimization
Translated At: 2025-08-16T01:14:46Z