Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One reason you may not see CTE's or temp tables included in these articles is because their specifics are tightly coupled to the schema of your DB. It's hard to write a generic example in Stack Overflow that would work for someone else.

But like you said: if you know the DB schema then temp tables make SQL easier to read, write, and reason about.



How are temp tables or CTEs more tightly tied to a schema than the original query? They both reference the same set of tables and columns, and both depend on indexes being in place. A schema change will break both, in equal measure.


I'm not sure what you mean by this - it is possible to write any subquery as a CTE


Might refer to MySQL. It didn’t support any CTEs until version 8.0, from April, 2018.


I'm not sure if I like the idea of using CTEs as an optimization fence. It means using implementation quirks that can be changed in future releases.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: