首页 > 数据库 > SQL Server > 正文

Sql server 2005带来的分页便利

2024-08-31 00:49:02
字体:
来源:转载
供稿:网友

select threadid from
(
select threadid, row_number() over (order by stickydate) as pos from cs_threads
) as t
where t.pos > 100000 and t.pos < 100030

===========================================

如果里面的这个表cs_threads数据量超大,比如,几亿条记录,那这个方法应该是有问题的

因为,select threadid from
(
select threadid, row_number() over (order by stickydate) as pos from cs_threads
) as t
where t.pos > 100000 and t.pos < 100030
这个语句是把select threadid, row_number() over (order by stickydate) as pos from cs_threads它全部取出来,然后在sql的外面进行分页的,没在sql2005上测试过,因为原先在oracle上这样的写法是不好的,oracle中这样写比较好:select threadid from
(
select threadid, row_number() over (order by stickydate) as pos from cs_threads a where a.pos<100030
) as t
where t.pos > 100000


 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表