Matt
Matt

Reputation: 26971

In MS SQL Server, inserting Rows into a table variable became painfully slow all the sudden

In MS SQL Server 2008, inserting Rows into a table variable became painfully slow all the sudden. 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.

Upvotes: 2

Views: 1341

Answers (1)

Adriaan Stander
Adriaan Stander

Reputation: 166396

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.

Upvotes: 2

Related Questions