4 ms·
CTEs are found in SQL Server as well: http://technet.microsoft.com/en-us/library/ms190766(v=sql.105).aspx http://technet.microsoft.com/en-us/library/ms190766(v
by brunnsbe 13y ago
CTEs are found in SQL Server as well:
http://technet.microsoft.com/en-us/library/ms190766(v=sql.105).aspx http://technet.microsoft.com/en-us/library/ms190766(v=sql.10...
- pradocchia 13y agobut CTEs in SQL Server are not an optimization boundary like they are in Postgres. This makes a big difference in their proper use. In SQL Server, aside from recursion, CTEs are purely syntactic sugar and thus a tool for organizing code. Whereas in Postgres, due to the optimization boundary, they are a tool for query tuning. If you rewrite a query in Postgres using CTEs just to clean it up, you are doing it wrong, since the CTEs will also affect the planner.
- radiowave 13y agoRight, but that's assuming that performance is the most pressing constraint. Sometimes it's confidence in the query producing the right result, or maintenance further down the line.