I was recently working in a very slow stored procedure (took 5 minutes to run). I made a very small tweak from doing this:
declare @tempTable table
(
...
)
insert into @tempTable
select .....
to
select ... into #tempTable from someTable
The script then ran in ~2 seconds. What can explain this time difference?