JSP pages, performance comparison of result set pagination and SQL (top) paging

Source: Internet
Author: User

JSP page two paging modes:

The first: Result set paging, the main code is shown below:

Java code
  1. ResultSet rs=stmt.executequery (SQL);
  2. ResultSetMetaData Md=rs.getmetadata ();
  3. Rs.beforefirst ();
  4. Rs.absolute (2000);
  5. }
  6. int ii=0;
  7. while (Rs.next () &&ii<=)
  8. {
  9. Rs.getstring ("xxx");
  10. ii++;
  11. }



Second type: SQL statement paging

Sql= "Selec top id,name from table where ID not in (select top with ID from table)";



The two kinds of paging test, in the case of 4 million data, the performance is almost the same, the difference is not small. The speed is about 30 seconds.

Test data (20 per page):
SQL paging

Page time
2--test2 Starttime=mon Oct 16:24:35 CST 2009
2--test2 Endtime=mon Oct 16:25:09 CST 2009 34

200--test2 Starttime=mon Oct 16:25:48 CST 2009
200--test2 Endtime=mon Oct 16:26:21 CST 2009 33

20000--test2 Starttime=mon Oct 16:27:04 CST 2009
20000--test2 Endtime=mon Oct 16:27:39 CST 2009 35

210000--test2 Starttime=mon Oct 16:28:22 CST 2009
210000--test2 Endtime=mon Oct 16:29:58 CST 2009 36


100000--test2 Starttime=mon Oct 16:30:30 CST 2009
100000--test2 endtime= Mon Oct 16:31:10 CST 2009 40


----result set pagination

2--11start time Mon Oct 16:33:37 CST 2009

2---55end time Mon Oct 16:34:12 CST 2009 35


200--11start time Mon Oct 16:34:59 CST 2009

---55end time Mon Oct 16:35:32 CST 2009 33


20000--11start time Mon Oct 16:36:26 CST 2009

20000---55end time Mon Oct 16:36:59 CST 2009 33


210000--11start time Mon Oct 16:38:00 CST 2009

210000---55end time Mon Oct 16:38:33 CST 2009 33


100000--11start time Mon Oct 16:39:10 CST 2009

100000---55end time Mon Oct 16:39:43 CST 2009 33

JSP pages, performance comparison of result set pagination and SQL (top) paging

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.