开发者

SQL: Locking on temp tables

Are locks taken out when querying a temp table? If so, how granular are they by default? Is there a performance hit similar to locking normal rows/table?

I assume no locks are taken because temp tables (at least as of SQL 2008开发者_运维技巧) are created per instance.

select x,y,z into #MyTempTable
from SomeOtherTable


  • A temp table like this is local to your connection. It can't affect concurrency because no-one else can read it.

  • Temp tables generally behave like normal tables for concurrency, isolation, locks, transactions etc

  • You may (or may not!) get tempdb contention (link about TF 1118) under heavy load which isn't the same as table locking

  • Is your question prompted by one of those SQL Server 6.x myths (DBA.SE)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜