how to improve performance by using or not using table variables I have a table variable:

DECLARE @to_process TABLE 
(
    [Id] [bigint] NOT NULL,
    [SequenceId] [bigint] NOT NULL,
...
)


INSERT INTO @to_process
   (  Id
    , SequenceId
...
   )
  SELECT
    TOP (@recordsToProcess) 
      Id
    , SequenceId
...


in my stored procedure. I have investigated that insert into it spends about 66% of total execution time. 


How can I improve or optimize my code to speed up my sp execution?

ADDED:
First thought...

If you have sufficient data to take this much % of the batch, use a #temptable.

When the table variable is used later, it is always assumed to have one row: there are no statistics on this table variable. So if you have several 1000, subsequent plans won't be optimal.

Temporary tables have statistics (and indexes if required etc) and can perform better for larger datasets