Why is insert a) so slow compared to insert b)?
When executing the select statement select_statement below (without the insert into part), the query terminates in app. 4 seconds. It is a select from a indexed table with appr. 30 million records.
The insert statement a) terminates in 11 seconds(??)
The insert statement b) terminates in 4 seconds (the same amount of time as the select itself)
a)
declare @Test table
(
stackerNbr varchar(9)
)
insert into @Test(stackerNbr) select select_statement
b)
create table #Test(stackerNbr varchar(9))
insert into #Test(stackerNbr) select select_statement