Comparison of several pagination display in ASP

Source: Internet
Author: User
Compare | pagination | Show the following comparison to see how the comparisons are used in several ways.

One, there are two ways to use stored procedure paging:

First, use the command object, as follows:

Setcmd=server. CreateObject ("Adodb.command")

Cmd.activeconnection=conn

cmd.commandtext= "Ycuu_gb_getmsg"

Cmd.commandtype=4 ' adCmdStoredProc

Cmd.prepared=true '

Setparam=cmd.createparameter ("@iPageNo", Adinteger,1,2,page)

Cmd.Parameters.Appendparam

Setparam=cmd.createparameter ("@iPageSize", Adinteger,1,2,pagesizeconst)

Cmd.Parameters.Appendparam

Setrs=cmd.execute

The second type is executed directly using the connection object's execution method, as follows:

Setrs=conn.execute ("executeycuu_gb_getmsg" &page& "," &pagesizeconst)

Second, do not use stored procedures, directly using the Adodb.recordset function to pagination, the specific code is as follows:


Setrs=server.createobject ("ADODB.") Recordset ")

Sql= "Select*fromguestbookorderbydateandtimedesc"

rs.opensql,conn,1,1

Rs.pagesize=150 ' The number of messages displayed per page,

Total=rs. RecordCount

Mypagesize=rs.pagesize

Rs.absolutepage=page

To show the speed more clearly, I've increased the number of messages displayed on each page to 150 (in fact, I wouldn't have set such a large value). As for the configuration of my machine, I omit to say it, because it is mainly speed contrast.

Found that the time of execution is as follows:

The first: stable in 0.1953125 seconds to 0.2109375 seconds, the average is about: 0.20 seconds

The second: stable between 0.1716875 seconds to 0.1857 seconds, the average is approximately: 0.177 seconds

Third: Stable between 0.4375 seconds to 0.4632 seconds, the average is approximately: 0.45 seconds

However, when the number of record bars read is 20, the result is as follows:

Found that the time of execution is as follows:

First: Stable in. 0390625 seconds to 0546875 seconds, the average is about 0.045 seconds.

Second: Stable in 0.046875 seconds to. 0546875 seconds, the average is approximately: 0.050 seconds

Third: Stable in. 09375 seconds to 0.1015625 seconds, the average is approximately: 0.97 seconds

In this view, it seems that the two ways of Conn.execute and Command.Execute seem to be very different,

And the former way of calling seems simpler.

At the same time, you can see that the paging stored procedure is much faster than the recordset's paging speed.

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.