On Snowflake or modern Postgres, CTE vs subquery barely matters for performance. On Redshift, it can matter a lot — and I learned this the hard way. The assumption I carried over I carried an assumption over from Snowflake: that the optimizer would treat a CTE and an equivalent subquery the sam...
Source: [Dev.to](https://dev.to/maithreyan11/why-cte-vs-subquery-matters-more-on-redshift-than-anywhere-else-llm)