【发布时间】:2011-01-28 06:23:58
【问题描述】:
我有一个问题:
Select a from tbl_abc where id in ( select id from tbl_xyz where mainid = 12)
当我执行这个查询时,执行需要 1-2 秒,但是当我在存储过程中使用相同的查询时,下面的查询需要超过 5 分钟:
If(Select a from tbl_abc where id in ( select id from tbl_xyz where mainid = 12))
BEGIN
-- CREATE TEMPORARY TABLE [Say: #temp1]
#temp1 => Select a from tbl_abc where id in ( select id from tbl_xyz where mainid = 12)
inserting the same value in the temp table
drop #temp1
END
这可能是什么原因?我该如何解决这个问题?我正在从 asp.net 运行 SP
【问题讨论】:
-
为什么是 IF 语句?你想做什么?
-
你检查过查询计划和 io/cpu 统计信息吗?
-
对于那些面临同样问题的人:两个答案 [by: binil & by: gbn] 对我有用。
标签: asp.net sql-server sql-server-2005 executiontimeout