performancesql-server-2008-r2common-table-expressiontemp-tablestable-variable

CTE (Common Table Expression) vs Temp tables or Table variables, which is faster?


CTE (Common Table Expression) vs Temp tables or Table variables, which is faster?


Solution

  • We got a 50% increase in speed moving to CTE in one particular case so it's worth giving it a go but any performance related enhancements need to be bench marked so you can compare one against another.

    PS: we wrote more than one query with a CTE in it before we got the one we now use.