--快
1. select top 100 * from test where c1 < 30000 order by c2

--慢
2. select top 101 * from test where c1 < 30000 order by c2

 1. is more than  two times faster than 2.

 

 

CREATE TABLE [dbo].[NUM]
([n] int NOT NULL, s varchar(128) NULL, PRIMARY KEY CLUSTERED([n] ASC))
go
-- populate data
set nocount on
declare @n int, @i int
set @n=1000000
set @i = 0
while @n>0 begin
if @i = 0 begin tran
insert into dbo.NUM
select @n, convert(varchar,@n + @i * 2)
set @n=@n-1
set @i = (@i + 1) % 1000
if @i = 0 commit
end
GO
-- test 1
select  top ( XX ) cast(s as int), n from dbo.num
order by cast(s as int) desc
go
-- test 2
set rowcount XX
select cast(s as int), n from dbo.num
order by cast(s as int) desc

for test 1, duration < 1s, for any XX <= 100, and the duration is about 12s for any XX >100

for test 2, the duration is fixed at 4s for XX: 10  - 100,000.