我有一个查询:不同的执行时间相同的查询 - SQL服务器
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语句?你想做什么? – gbn 2011-01-28 06:32:02
您是否检查过查询计划和io/cpu统计信息? – sisve 2011-01-28 07:27:10
对于那些面临同样问题的人:两个答案[by:binil&by:gbn]都适合我。 – Zerotoinfinity 2011-01-28 08:49:05