Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.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/8/sorting/2.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 server Sql行数和低级别转换速度在哪里以及如何提高?_Sql Server - Fatal编程技术网

Sql server Sql行数和低级别转换速度在哪里以及如何提高?

Sql server Sql行数和低级别转换速度在哪里以及如何提高?,sql-server,Sql Server,我的表中有一个2lakhs数据。我只想访问40个数据。 这里的问题是,下面的查询何时被触发 select a.* from (select row_number() over (ORDER BY columnid1) as srno,* from table where columnid1 between 1 and 20 and

我的表中有一个2lakhs数据。我只想访问40个数据。 这里的问题是,下面的查询何时被触发

    select a.* from 
         (select 
               row_number() over (ORDER BY columnid1) as srno,* 
          from table 
          where 
               columnid1 between 1 and 20 
               and  columnid2 like '%A%'
               and  columnid3 between 20 and 25
         ) as a
        where a.srno>=5200 and a.srno<=5240
然后在12秒后给出结果


如何提高我的访问速度?

您的行中没有订单\u数字表达式选择1是无订单。这意味着您无法控制得到的行数,因此您可以重写查询以获得前40行。那应该更快。否则,您应该看看执行计划,看看是否可以对索引/聚集索引做些什么。由于您没有order by,如果添加一个可以提高性能的索引,您很可能会得到不同的结果集。我必须使用order by和40行,现在我要做什么?像“%a%”一样执行…columnid2。。在您的内部查询中,几乎可以保证它不能在columid2上使用索引-因此我不知道如何加快速度-除了更改搜索条件之外,如果您想要提高速度,请不要使用“%”…%”