• Not sure if any of what follows explains what you're seeing:

    Have you looked at the execution plans on each of the boxes? Since prod is timing out, can you try it for just a handful of rows?

    In my experience, tablevars with more than 10 000 rows are slower than #temp tables, index or no index.

    Table vars do not necessarily exist in RAM: if they get big enough, they are created in tempdb, just like #temp tables.

    As an aside, while loops and cursors usually amount to row by row processing, one doesn't save much doing it one way or the other. Neither would be an improvement - most of the time.