Temporary tables may cause recompilation. This only happens because they are processed like regular tables using the SQL Server Engine. When the tables (which contain the main queries) have changed significantly, SQL Server detects this change (using automatic update statistics) and notes that the dependent queries are recompiled so that the next execution can create an optimal execution plan.
After the temp table or queries that depend on the temp table are changed, the query engine will not be able to execute the same caching plan because it will not consider the query.
It should be noted that table variables do not inherently cause recompilation. In some situations, this may be the best choice.
For more information on recompiling the temp table, see http://sqlserverplanet.com/optimization/temp-table-recompiles .
chaitanya.moguluri
source share