话说阻塞

今天下午程序部门开始在我们的数据服务器上跑如下sql:

DECLARE @Tfccc6dc969d446b0b7b7f5bfc1865227 table( AcceptCode varchar(20) ,Status smallint ,ExpressCompanyID int

)

insert into @Tfccc6dc969d446b0b7b7f5bfc1865227( AcceptCode, Status, ExpressCompanyID)

           select  '411123093727', '10', '353'

 union all select  '411123093818', '10', '353'

 union all select  '411123093914', '10', '353'

 union all select  '411123094000', '10', '353'

 union all select  '411123094286', '10', '353'

 union all select  '411123094820', '10', '353'

 union all select  '411123095655', '10', '353'

 union all select  '411123095678', '10', '353'

 union all select  '411123097476', '10', '353'

 union all select  '411123098394', '10', '353'

 

 update o set

 o.Status =  (case when f.status='60' or f.status= '80' then f.status else o.status end) , o.ExpressCompanyID = f.ExpressCompanyID  from AcceptForm as o join @Tfccc6dc969d446b0b7b7f5bfc1865227 as f on  o.AcceptCode = f.AcceptCode

 

发现一个怪异现象,第一执行的时候需要1分钟,第二次只需要10毫秒。

看执行计划,本语句没有任何问题。

跟缓存也没有任何关系。

sp_who2发现两个id出现锁丶wait情况,根据object_id找到相关资源。

问题找到了,原来是因为某程序阻塞了以上sql语句,我们停掉了某程序,该sql语句执行正常。

posted on 2011-12-31 17:12  xiaohuime  阅读(168)  评论(0编辑  收藏  举报