If I run a CTE does that materialize the resulting data in the same (or a similar) way as if I created a temp table and referred to that instead? Or does the CTE keep the set in memory?
Really good question, I too would be interested in this.
I'd expect it'd materialize to RAM if the result is within `work_mem` but I'd love to know for sure.