高性能SQL分页语句
第一种方法:效率最高
|
存储过程 (表名aa)
|
第二种方法:效率次之
|
存储过程(表名 aa)
if(exists(
select
*
from
sys.procedures
where
name
=
'p_location_paging'
))
drop
proc p_location_paging
go
create
proc p_location_paging(@pageSize
int
,@currentPage
int
)
as
select
top
(@pageSize) *
from
aa
where
locId>(
select
ISNULL
(
MAX
(locId),0)
from
(
select
top
((@pageSize)*(@currentPage-1))locid
from
location
order
by
locId)
as
a
)
order
by
locId
第三种方法:效果最差
|
原文地址 https://blog.csdn.net/scholar_man/article/details/80782324