表A有两千万条数据,有SequenceCode列,类型为Int,值是顺序数字。
code, sequncecode
aabcb1233, 1
xxxxb1233, 2
zzfdsb123, 3
.......
pupjfs233, 20000000
因为听说SQL SERVER对于TOP有特别的优化,所以请问如下两个语句,哪个效率更高
select top 10 * from 表A where sequncecode >= 10080
select top 10 * from 表A where sequncecode between 10080 and 10099
------解决方案--------------------
select top 10 * from 表A where sequncecode >= 10080
select top 10 * from 表A where sequncecode between 10080 and 10099
你这两个都不同的语句,如果你的数据只到10099,而且有索引,那么下面那个快