4 ms·
Care to elaborate on what situation would a CTE improve performance? Because the OP itself mentioned CTEs degrading performance.
by bigato 10y ago
Care to elaborate on what situation would a CTE improve performance? Because the OP itself mentioned CTEs degrading performance.
- blowski 10y agoIt wouldn't improve performance, but it might improve readability without denigrating performance. I don't have much experience with CTEs, but I do have lots of experience trying to debug unreadable SQL.
- bigato 10y ago> Sometimes I understand the problem perfectly well, but a single beautiful query is not performant enough. > It wouldn't improve performance, but it might improve readability without denigrating performance. These two statements of yours are negating each other, unless people started using "performant" as synonymous for readable now.
- blowski 10y agoOK, a clarification. My first attempt at a query is readable but performance is terrible. I fix the performance problem, but the query is now much less readable. I use a CTE as a compromise between performance and readability.