zlacker

[parent] [thread] 2 comments
1. RaftPe+(OP)[view] [source] 2024-08-25 15:02:29
CTE's (at least in MS SQL land) are a syntax level operation, meaning CTE's get expanded to be as if you wrote the same subquery at each place a CTE was, which frequently impacts the optimizer and performance.

I like the idea of CTE's, but I typically use temp tables instead of CTE's to avoid optimizer issues.

replies(1): >>wvenab+al
2. wvenab+al[view] [source] 2024-08-25 17:12:48
>>RaftPe+(OP)
If you use temp tables you're subverting the optimizer. Sometimes that's what you want but often it's not.
replies(1): >>RaftPe+HU
◧◩
3. RaftPe+HU[view] [source] [discussion] 2024-08-25 20:51:47
>>wvenab+al
I use them on purpose to "help" the optimizer by reducing the search space for query plan ((knowing that query plan optimization is a combinatorial problem and the optimizer frequently can't evaluate enough plans in a reasonable amount of time).
[go to top]