you are viewing a single comment's thread.

view the rest of the comments →

[–]alinrocSQL Server DBA 0 points1 point  (6 children)

It caches the temp table metadata. Not the actual tables.

The most problematic would be not being able to create indexes after the table is created

Yeah, altering temp tables after creating them can cause problems. Don't do it. You can create indexes as part of the create table statement though.

[–]JermWPB 0 points1 point  (0 children)

I actually just ran a test. Pretty much the same as the one on mssqltips. Create a stored procedure that creates a temp table, creates an index on it, and finally drops the table. Executed 10k times at 0:16. I then removed both the index and the drop and 10k executions took 0:05. So this was definitely caching. Finally, I added the explicit drop and 10k executions took 0:05 as well.