Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 为什么select和subselect在条件下不返回行的速度要慢得多?_Sql_Sql Server_Sql Server 2014 - Fatal编程技术网

Sql 为什么select和subselect在条件下不返回行的速度要慢得多?

Sql 为什么select和subselect在条件下不返回行的速度要慢得多?,sql,sql-server,sql-server-2014,Sql,Sql Server,Sql Server 2014,我有一个相当复杂的选择,看起来像这样 select Columns from TablesWithJoins where MainColumn in (select AnotherColumn from OtherTablesWithJoins) 问题是,选择通常在100毫秒以下结束() 当subselect不返回行时,其执行时间比必须无条件返回所有记录时长得多。() 你知道为什么会发生这种情况以及如何避免吗 添加了的版本存在。()

我有一个相当复杂的选择,看起来像这样

select Columns 
  from TablesWithJoins 
 where MainColumn in (select AnotherColumn from OtherTablesWithJoins)
问题是,选择通常在100毫秒以下结束()

当subselect不返回行时,其执行时间比必须无条件返回所有记录时长得多。()

你知道为什么会发生这种情况以及如何避免吗

添加了
的版本存在
。()