Home>

The following is the test code to improve the efficiency of paging when there is a large amount of data.Share it with everyone.

--Improve paging efficiency:only display data is read when paging is implemented,Need to create the database "testforpaging" in the database first
use testforpaging
go
--Create table somedata
create table somedata
(
id int primary key,name varchar (30) null,description text
)
go
--Insert data
insert into somedata values ​​(1, "num1", "Article 1")
go
insert into somedata values ​​(2, "num2", "Article 2")
go
insert into somedata values ​​(3, "num3", "Article 3")
go
insert into somedata values ​​(4, "num4", "Article 4")
go
insert into somedata values ​​(5, "num5", "Article 5")
go
--Total number of data entries
select count (*) from somedata
go
-Add a data level to each record
select name, description, row_number () over (order by id desc) as datalevel from somedata
go
--View data entries between specified data levels
select datalevel, name, description from
(select name, description, row_number () over (order by id desc) as datalevel from somedata)
 as datawithleverl where datalevel between 2 and 4
go
-A stored procedure to view data entries between specified data levels
create procedure getdatapaged
(
@startrowindex int,@maximumrows int,@sort varchar
)
as
-Make sure to specify sort
if len (@sort)=0
[email protected]="id"
--Query with parameters
select datalevel, name, description from
(select name, description, row_number () over (order by @sort desc) as datalevel from somedata) as datawithleverl
where datalevel>(@ startrowindex * 10) and datalevel<= (@ startrowindex * 10 + @maximumrows)
go
  • Previous jQuery simple implementation of page elements on top of the hover effect example
  • Next Threejs learning text shapes and custom shapes