In MS SQL Server 2008, inserting Rows into a table variable became painfully slow all the sudde开发者_开发百科n. The creation of a table variable and query and insertion rows is done in a sproc and it has become terribly slow.
The query completes virtually instantly, returns a small set (10 rows of 1 column of ints), and takes upward of 50 seconds to insert into the table variable. I switched back to temp tables and that is fine, the operation happens in a few microseconds.
From table (Transact-SQL)
Queries that modify table variables do not generate parallel query execution plans. Performance can be affected when very large table variables, or table variables in complex queries, are modified. In these situations, consider using temporary tables instead.
精彩评论