3 ms·
Postgres has no problems joining against any sized CTEs - at least that's what I'm seeing here with a considerably sized dataset (600 GB raw table size). But:
by pilif 13y ago
Postgres has no problems joining against any sized CTEs - at least that's what I'm seeing here with a considerably sized dataset (600 GB raw table size).
But: The optimizer will first fully resolve the CTE expression and only then join. If the join condition eliminates many of the rows selected in the CTE, this might indeed yield a much worse execution time than doing it inline.
This behaviour is documented on http://www.postgresql.org/docs/9.3/static/queries-with.html http://www.postgresql.org/docs/9.3/static/queries-with.html (at the end of 7.8.1)