4 ms·
Great article, I always like to structure my queries with CTEs and I was (wrongly) assuming it all gets inlined at the end. Sometimes it also gets complicated
by uwemaurer 6mo ago
Great article, I always like to structure my queries with CTEs and I was (wrongly) assuming it all gets inlined at the end.
Sometimes it also gets complicated since these intermediate results can't be easily seen in a SQL editor. I was working on a UI to parse CTE queries and then execute them step by step to show the results of all the CTEs for easier understanding of the query (as part of this project https://github.com/sqg-dev/sqg/ https://github.com/sqg-dev/sqg/)
- siddboots 6mo agoI think your assumption about inlining is essentially correct. As far as I know postgres was the last major rdbms to have an optimiser fence around CTEs.
- nraynaud 6mo agoI concur, “the Germans” have created an algorithm that completely “see through” subqueries/CTEs when planning a query. The way the query is written has no bearing on the execution.
- atombender 6mo agoBy the Germans, as you referring to Thomas Neumann's database group at TMU, Munich?
- atombender 6mo ago*TUM (Technical University of Munich).