5 ms·
Creating views makes more sense sometimes and CTEs make more sense other times. Creating views just for one query is kind of like creating temporary variables
by jeffdavis 7y ago
Creating views makes more sense sometimes and CTEs make more sense other times.
Creating views just for one query is kind of like creating temporary variables for each subexpression. Sure, it works, but not a great solution.
Also, other databases do optimize through a CTE. So if you port to PG 11, you might see a lot of regressions in plans unless you rewrite to use views instead. PG 12 will work a lot better for existing queries.