4 ms·
CTEs effectively act as optimisation barriers; up to loading all the rows, there is essentially no push down of conditions into the CTE. This is contrasted with
by alexchamberlain 6y ago
CTEs effectively act as optimisation barriers; up to loading all the rows, there is essentially no push down of conditions into the CTE. This is contrasted with a sub query that will respect pushed down conditions. That being said, a CTE may be beneficial if it produces a small number of rows that are used a lot, or if you're simply using it for readability purposes.
- minxomat 6y agoCTE are no longer definitive optimization barriers, as recent Postgres versions will always inline side effect free CTE.
- alexchamberlain 6y agoI'd totally missed that; how recent us recent?
- minxomat 6y agoI think PG12. You can force no inlining using MATERIALIZED CTE.