I use 5 million of the data to test, interested people can try tens;1. Add a lot of data firstSQL SERVER millions data test "measurement"2. Normal pagingA,row_number () over select * (select row_number () over ( Span style= "color: #0000ff;" >order by t.userid) as row, * from Users as as TT where tt.row between 999000 and 1000000 ; Test: "Millions" first page time:126MS, 100W time 1073MS, close to the first page 10 times times,500W
Projects often used in the table, the large amount of data also needs to be paging, project design phase, I chose the bootstraptable JS plug-in, personally feel that this framework is very useful, support server-side paging, this article mainly written about server paging. T
=sqlhelper.executequery (SQL, NULL);
try {
if (Rs.next ()) {
int rowcount=0;
Rowcount=rs.getint (1);
Pagecount= (rowCount-1)/pagesize+1;
}
} catch (SQLException e) {
//TODO auto-generated catch block
e.printstacktrace ();
}
return pagecount;
} SQL Server However, in SQL Server, the LIMIT statement is not supported. What do we do?Solution:Although SQL Server does
methods just one more column of Rewnumber? Of course not, look at the internal differences:
On two SQL, add the following SQL separately, and use MS's include execution plan to facilitate viewing execution details:
SET STATISTICS time on
SQL to execute:
SET STATISTICS time in
go
select top numcomimg.* from
(select Row_number () over (order by ID ASC) as RowNum ber,* from (SELECT * FROM [tccline].[ DBO]. [Cline_commonimage]) As Comimg)
as numcomimg where rownumber>40
SET
When using Row_number paging, you may need conditions, such as displaying information below an ID for paging, and so on, which need to be judged by conditions.SELECT * FROM (select Row_number () over (order by ID) as NUM, * from [SJK] where id=xxx) as T where T.num>=0 and T.NUML T;=20In this there is a clear need to find information about an ID. But this where condition cannot be placed outside, on the outs
Tags: blog c java tar http aRecently summarized the database paging SQL usually used in the project. You can post more efficient SQL statements with paging.SQL Server PagingThe first method of pagingParameters to be required:PageSize How many data are displayed per pagePageNumber pages coming from the clientTotal number of records in the Totalrecouds table select COUNT (*) from table nameTotalPages Total Pa
(Order byID) RowNumber,* froma) A1whereRowNumberbetween to and +--method Six: Row_number () variant, not based on existing fields to produce the record ordinal, first by criteria filtering and sequencing, and then on the result set to a constant column to generate the record sequence numberSelect * from(SelectRow_number () Over(Order byID) RowNumber,* from(Select Top + * fromAwhere 1=1 Order byID) a) bwhereRowNumber> -Iv. SQL statement Efficiency testDeclare @begin_date datetimeDeclare
Pageindex.indexid ORDER BY
Pageindex.indexid
End
In SQL Server 2000, because there is no effective method for ranking operations, the example first creates a temporary table with an identity field, taking advantage of the self-growth characteristics of the identity field. Indirectly, a line number is assigned to each row of the Orders table by OrderID, and then pagination is implemented based on this line number.
In SQL
Example of using bootstrap-table to implement server paging (spring background ),
Recently, the bootstrap table plug-in is used on the front end. If the client page contains a large amount of data, it is difficult to interact with each other. Therefore, pages with large data volumes are used on the server side. The following starts the commit code:
Front end
Firs
SQL Server database paging query has been SQL Server's short board, Idle to do nothing, think of several methods, assuming that there is a table article, Field ID, year ... (other omitted), Data 53,210 (customer real data, amount of small), page 30 per page, query page 1500th (that is, 第45001-45030条 data), field ID clustered index, Year no index, SQL Server versi
flowersLet's look at an example before we introduce this section to subvert your thoughts and make you mad.' Jeffckywang ') As Col1So it's okay, we'll insert it into the table and look at the description of its columns' Jeffckywang ' 'dbo. IsNullExample2';The data in the table does exist, but the description of the column is nullable.SummarizeThe above focus on the differences between coalesce and ISNULL functions, through this section of the two scenarios and differences, we should have a lit
In normal project development, the paging stored procedure uses a large number of stored procedures. top is often used in the SQL Server paging stored procedure, and RowNum is often used in Oracle.
Now, there is a UserInfo table, where one field is UserId and the other is UserName, where UserId increases automatically and step size is 1. there are 30 data records
Label:JdbcTemplate + SQL Server 2005 Paging +extjs PackageCom.ur.util;ImportJava.util.List;ImportJava.util.Map;ImportOrg.springframework.jdbc.core.JdbcTemplate; Public class pagination {
Public Static Final intNumbers_per_page = -;Private intoffset =0;Private intLimit = -;Private intTotalSize;PrivateListPrivateJdbcTemplate jtemplate; Public pagination() {
} Public pagination(String SQL,intOffseti
is, they have to take out of the database No. 0 to 1010th of the data so that the query out of the number of records, but the amount of data transmission network is very large!
Therefore, a better paging approach should be:
Retrieve data from a block of page size only from the database each time you page. In this way, although each page will need to query the database, but the number of records to query out a small amount of data transmission n
) WORDER byW. Year ASC, W.idASC ) ORDER byW1. Year DESC, W1.idDESC The fifth option:SELECTW2.N, W1.* from(SELECT TOP 50030Row_number () Over(ORDER by Year DESCIdDESC) n, ID fromarticle) W2, article W1WHEREW1.id=w2.id andW2.n> 50000 ORDER byW2.nASC In the query of the front page, efficiency 3>4>5>2>1, page after the 5>4>3>1>2, and then according to user habits, the general user's search only see the first few pages, so choose 3 4 5 plan can be, if the comprehensive consideration of program
Tags: http os using Data SP problem c ADThe SQL Server table query in this program gets 16 data, when page=1, the executed SQL statement can find the results, and is also 10 dataWhen page=2, the second page of the data should be 6, but the execution of page=2 when the SQL statement, the results of the query is empty! What is this for?Reasoning, the SQL statement seems to have no problem, the last little analysis, found the problem, query time N.rid as
Tags: using ar sp data div art on BS sizePaged query statements that are used in different databases:Current page: CurrentPagePage Size: pagesize1. Oracle DatabaseSELECT * FROM (select A.*,rownum rn from (query_sql) A) where Rn Note: query_sql is a query SQL statement.OrSELECT * FROM (select RowNum rn,id from TABLENAME where RowNum 2. Infomix DatabaseSelect Skip CurrentPage First pagesize * from TABLENAME3. DB2 DatabaseSELECT * FROM (select field 1, Field 2, Field 3,rownumber () over (order by s
Create a table on the classic page of the SQL Server Stored Procedure: CREATETABLE [TestTable] ([ID] [int] IDENTITY (100) NOTNULL, [FirstName] [nvarchar] () COLLATEChinese_PRC_CI_ASNULL, [LastName] [nvarchar] (100) COLLATEChinese_PRC_CI_ASNULL, [Country
CREATE a TABLE on the classic page of the SQL Server Stored Procedure: CREATE TABLE [TestTable] ([ID] [int] IDENTITY (1, 1) NOT NULL, [FirstName] [nvarchar]
Write in frontStarting with SQL Server 2005, provided the Row_number () function, using the function generated by the index to handle paging, according to normal logical thinking is to pass pageindex and pagesize to complete the paging, the front end and I communicated yesterday, They use JQuery.DataTable.js plug-ins, and through the company's bottom-level packag
Label:Translated from: http://www.cnblogs.com/Bulid-For-NET/archive/2012/12/16/2820097.html Data paging for SQL Server: Suppose you now have a table like this:CREATE TABLE Test(ID int PRIMARY key NOT NULL identity,Names varchar (20))And then insert about 1000 data into it for the page test.Assuming the number of pages is 10, now to take out the contents of page 5th, the query statement is as follows:--10 r
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.