读书人

关于“TOP”的效率有关问题

发布时间: 2012-10-19 16:53:35 作者: rapoo

关于“TOP”的效率问题求助
表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,而且有索引,那么下面那个快

读书人网 >SQL Server

热点推荐