日期:2014-05-18  浏览次数:20425 次

一个在查询分析器中执行很快,结果只有一条的语句,为什么会阻塞?
一个在查询分析器中执行很快,结果只有一条的语句,为什么会阻塞数据库,导致IIS占用内存升高,web应用程序死掉.

------解决方案--------------------
嘿,2年前我也遇到过这样的情况,一个join查询,改为in子句就好了,按道理join比in效率高啊?当时比较急,改了能用了就算了,也没深究,到现在也没弄明白怎么回事! 不好意思,说了这一堆也没帮上你,全当帮顶......
------解决方案--------------------
把你的語句貼出來看看
------解决方案--------------------


p.id? 是b.id吧!

按道理说,不应该有死锁。

检查是否有其他进程锁定了资源。

可以加上with (nolock),指定查询时不锁定,如:


select b.phone,b.NameCN
from table1 as a with (nolock)
inner join table2 as b with (nolock) on a.sid=b.sid
where a.id = 'abc123458 '
and b.sid not in (24793,24479,135920,24477)
------解决方案--------------------
select
b.phone,b.NameCN
from table1 a with (nolock) join table2 b with (nolock)
on a.sid=b.sid
where a.id = 'abc123458 '
and b.sid not in (24793,24479,135920,24477)
-----------
select
b.phone,b.NameCN
from table2 b with (nolock)
where exists(select 1 from table1 with (nolock) where sid=b.sid and id= 'abc123458 ')
and b.sid not in (24793,24479,135920,24477)


這個試試看


------解决方案--------------------
select b.phone,b.NameCN from table1 as a, table2 as b where a.id = 'abc123458 '
and a.sid=b.sid and p.sid not in (24793,24479,135920,24477)

这么简单的语句,应该是不会的.
往其他方面想想.