Ok. Here\'s what I try to run:
USE tempdb;
SELECT TOP 1000000 IDENTITY(INT, 1, 1) Number
INTO Numbers
FROM sys.objects s1
CROSS JOIN sys.objects s2
CROSS J
-
Rather than chase this problem, why don't you just create the table once in the model
database, then it will be created for you in tempdb
automatically?
For the actual problem, we don't know. My first guess would be that your initial size for your tempdb file(s) is very small (like, 1MB). So, when you create the table, it has to expand the file(s) to accommodate it. This can be quite expensive especially if you don't have instant file initialization enabled, and it can also be very expensive to grow the log to accommodate the activity required there as well.
Other than that, we could keep guessing, but you will be better suited to investigate what is actually happening. Questions you'll want to ask:
- For the spid that is trying to create the table, what does
sys.dm_exec_requests
say for wait_type
?
- Does it have a
blocking_session_id
?
- If so, what is that session doing?
- 热议问题