2 ms·
Just be aware that CTEs add optimizer barriers in PostgreSQL. So a query like: SELECT * FROM ( ... ) AS results may have a completely different query
by cpburns2009 8y ago
Just be aware that CTEs add optimizer barriers in PostgreSQL. So a query like:
SELECT *
FROM ( ... ) AS results
may have a completely different query plan than a query like
WITH results AS ( ... )
SELECT *
FROM results
This may or may not be desirable, and is important to be aware of.
- munk-a 8y agoIt is a balance always... but code maintainability isn't something to be dismissed. If utilizing CTEs greatly improves your readability it's probably worth utilizing CTEs until there is a performance need to switch off (and it's pretty trivial to de-CTE a query)