• λ我爱Aspx >> C#.Net >> 分页实现方法的性能比较
  • 分页实现方法的性能比较

  • :aspxer  Դ:5iaspx  :2007-7-30 6:13:07  ؼ:
  • 我们先给出几种主要的分页方法和核心语句,然后直接给出结论,有兴趣的读者可以看看后面的数据

    几种常用存储过程分页方法

    TopN方法

    select Top(@PageSize) from TableName where ID Not IN

    (Select Top ((@PageIndex-1)*@PageSize) ID from Table Name where .... order by ... )

    where .... order by ...

    临时表

    declare @indextable table(id int identity(1,1),nid int,PostUserName nvarchar(50))

    declare @PageLowerBound int

    declare @PageUpperBound int

    set @PageLowerBound=(@pageindex-1)*@pagesize--下限

    set @PageUpperBound=@PageLowerBound+@pagesize--上限

    set rowcount @PageUpperBound

    insert into @indextable(nid,PostUserName) select ReplyID,PostUserName from TableName order by ......

    select * from TableName p,@indextable t where p.ID=t.nid

    and t.id>@PageLowerBound and t.id<=@PageUpperBound order by t.id

    CTE--2005新语法,类似临时表,但是生命周期稍微不同,这里只是他的一个运用

    Ҷƪл˵?
  • һƪJDBC之代码重复使用
    һƪPhotoshop画笔为照片添加雪粉边框