日期:2014-05-18 浏览次数:20614 次
select * from table where id not in (select top 100 id from table order by id desc)
select * from table left outer join (select top 100 id as tId from table order by id desc) t on t.tId = table.id where t.tId is null
go if OBJECT_ID('tbl')is not null drop table tbl go create table tbl( id int identity(1,1), QQ VARCHAR(10) ) go declare @a int set @a=1 while @a<=1000000 begin insert tbl select ltrim(cast(RAND()*1000000000 as int)) set @a=@a+1 end select * from tbl where id not in (select top 100 id from tbl order by id desc) --110万条数据不加任何索引第一次30s,第二次24s select * from tbl left join (select top 100 id as tId from tbl order by id desc) t on t.tId = tbl.id where t.tId is null --110万条数据不加任何索引第一次24s,第二次24s