3 ms·
CTEs can go a long way toward that, as can stored procs
by gaius 8y ago
CTEs can go a long way toward that, as can stored procs
- dragonwriter 8y agoAs can views.
- danidiaz 8y agoLATERAL joins can help with reusing calculations https://www.periscopedata.com/blog/reuse-calculations-in-the-same-query-with-lateral-joins https://www.periscopedata.com/blog/reuse-calculations-in-the...
- infinite8s 8y agoWow that's a bad example. Any decent query engine (which I'm assuming Postgres has) would reuse common subexpressions.
- danidiaz 8y agoEven if duplicate expressions are optimized by the engine, they hurt the readability and maintainability of the query, especially if they are big and complex.