With clause (CTE) vs Temporary table

Question posted in Computer Software, Computer\IT Services on 11 2009
Rate question difficulty level 0 Votes
With clause or temporary table?
 
 
1 Answer
 
A CTE in this sense is a derived table. 
Derived tables can be a lot more performance than temporary tables.  This is because temporary tables by default
do not have indexing and you have to spare the expense of creating the table,
populating the data, and creating the index.  The optimizer is able to use all
the existing statistics and indexing available for a derived table/etc, which
makes it a more viable solution, in my opinion.
NOTE: the optimizer can use
statistics and optimize a temporary table; however, cannot do so for a table
variable. The best way to test is the see how each method performs, but I would
say the etc/derived table is probably the better method here.

credits to : http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/d2ab0c7c-e991-4e85-9c21-827e2d12ef2f

11/03/2009
 
 
Add an answer*
 
Email
Location: United States
db sql
Now hiring!
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------