Two methods and comparison of stored procedure calls in ASP

Source: Internet
Author: User
Beerfroth (original)
I have written a simple message book using SQL server and asp. I am constantly trying to find some differences in execution methods and time when messages are displayed on pages.
The following is a comparison of several methods.
1. There are two ways to use stored procedure paging:
First, use the command object as follows:
Set Cmd = server. CreateObject ("Adodb. Command ")
Cmd. ActiveConnection = conn
Cmd. CommandText = "ycuu_gb_getmsg"
Cmd. CommandType = 4 'admo-storedproc
Cmd. prepared = true'
Set param = Cmd. CreateParameter ("@ iPageNo", adInteger, 1, 2, Page)
Cmd. Parameters. Append param
Set param = Cmd. CreateParameter ("@ iPageSize", adInteger, 1, 2, PageSizeConst)
Cmd. Parameters. Append param
Set rs1_cmd.exe cute
The second method is to directly execute the connection object using the following method:
Set rs1_conn.exe cute ("execute ycuu_gb_getmsg" & page & "," & pagesizeConst)
2. Directly use the ADODB. RecordSet function for paging without using stored procedures. The specific code is as follows:
Set rs = Server. CreateObject ("ADODB. Recordset ")
SQL = "Select * FROM Guestbook Order By dateandtime Desc"
Rs. open SQL, conn, 1, 1
Rs. pagesize = 150 'number of messages displayed per page,
Total = rs. RecordCount
Mypagesize = rs. pagesize
Rs. absolutepage = page
In order to display the speed more clearly, I increased the number of messages displayed on each page to 150 (in fact, this is not a big value ). As for the configuration of my machine, I will ignore it, because it is mainly about speed comparison.
The execution time is as follows:
First, it is stable between 0.1953125 seconds and 0.2109375 seconds. The average value is about 0.20 seconds.
The second type is stable between 0.1716875 seconds and 0.1857 seconds. The average value is about 0.177 seconds.
The third type is stable between 0.4375 seconds and 0.4632 seconds. The average value is about 0.45 seconds.
However, when the number of records read is 20, the result is as follows:
The execution time is as follows:
The first type is stable between. 0390625 seconds and. 0546875 seconds. The average value is about 0.045 seconds.
The second type is stable between 0.046875 seconds and. 0546875 seconds. The average value is about 0.050 seconds.
The third type is stable between. 09375 seconds and 0.1015625 seconds. The average value is about 0.97 seconds.
In this case, the two methods, conn.executeand command.exe cute, seem to be slightly different,
The call method of the former seems simpler.
At the same time, we can see that the paging storage process is indeed much faster than the recordset paging speed.
PS: My younger brother posted a document for the first time. I found it hard to write a good article. I will try my best in the future. I hope you will forgive me for not writing well this time. Now, I want to ask the two methods, conn.executeand command.exe cute, which are better, because I found the latter method to execute the stored procedure on the Internet. I don't know why it's not as simple as the previous one.

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.