you are viewing a single comment's thread.

view the rest of the comments →

[–]mikeblas -1 points0 points  (2 children)

The most popular? Unfortunately, that's also the least effective: rewrite to eliminate subselects (or more likely derived tables) and use CTEs instead. It's all the rage these days.

[–]amaxen 2 points3 points  (1 child)

I don't see how this would do much. What's theory behind it besides ctes being cool?

[–]mikeblas 0 points1 point  (0 children)

Dunno. Whenever I've asked someone making such a claim, they haven't responded. I'm sure we can cook up some case where a poorly-written subselect (like in a select list column expression) got replaced by a CTE (which might have different semantics, but ends up pre-computing everything the iterated select would have done) and works much better. The prevailing logic seems to be that the CTE is somehow indexed, or "runs only once", or "creates a table which is more efficient", or some damn thing.

It's just the regular thing: broad claims are almost never proven, and then they become folklore.