且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

单个SQL Server表上的死锁

更新时间:2022-11-27 23:13:38

我会在Param1上向FooTable添加索引;没有它,DELETE会进行全表扫描,这将导致死锁问题。

I would add an index on Param1 to FooTable; without it, the DELETE is doing full table scan, and that'll create problems with deadlocks.

编辑

根据您的活动详细信息,它看起来像您有死锁,有阻塞,在进行一次删除时,许多删除正在排队。同样,在Param1上建立索引可以减轻这种情况,如果没有索引,则每次删除都将进行全表扫描以查找要删除的记录,而这种情况下,其他删除必须等待。如果在Param1上有索引,它将更快地处理,并且您现在看不到阻塞。

Based on your activity details, it doesn't look like you have deadlocks, you have blocking, many deletes are queueing up while one delete takes place. Again, indexing on Param1 would alleviate this, without it, each delete is going to do a full table scan to find the records to delete, while that is happening, the other delete's have to wait. If you have an index on Param1, it'll process much quicker and you won't see the blocking you are now.

如果您有死锁,系统将终止其中一个涉及的过程,否则将永远不会进行任何处理;带有阻塞的东西会处理,但是如果表很大,就会很慢。

If you have deadlocks, the system will kill one of the involved processes, otherwise nothing would ever process; with blocking, things will process, but very slowly if the table is large.