News for hackers. Stuff that matters.
Re:Good CTE, Bad CTE by jpalomaki on Tuesday March 31, 2026 @12:21PM (#47589734)
Sometimes easy performance trick is to split the CTE to separate queries, put the results to unlogged temporary tables and add whatever indexes the next step needs.

Obviously makes only sense for stuff like analytical queries that are not running constantly.

Re:Good CTE, Bad CTE by taeric on Tuesday March 31, 2026 @12:30PM (#47589863)
Worth underlying the OLAP versus OLTP divide you are speaking to on the close, there.
Re:Good CTE, Bad CTE by andsbf on Tuesday March 31, 2026 @12:43PM (#47590070)
An issue that has arise for me in some situations is that for more expensive/reporting queries we point to a db replica, where temporary tables are not an option.