Speed test using stored procedures, GetRows (), 100,000 data extraction-application Tips

Source: Internet
Author: User
Tags db2 first row
Existing 10W data, Access database save

Through normal extraction:
Copy Code code as follows:

<%
Set conn= Server.CreateObject ("ADODB.") Connection ")
C&server.mappath ("Db2.mdb")
Conn. Open ConnStr

Set rs = Server.CreateObject ("ADODB.") Recordset ")
sql = "SELECT * from people ORDER by id DESC"
Rs. Open sql,conn,1,1

Do but not Rs. Eof
Response.Write RS ("id") & | "
Rs. MoveNext
Loop
%>

Http://www.cnbruce.com/test/getrows/show1.asp

Takes 3,250.000 milliseconds with a total test average of about 3 seconds
==========================================================

Using Stored procedure extraction:
Copy Code code as follows:

<%
Set conn = Server.CreateObject ("ADODB. Connection ")
Set cmd = Server.CreateObject ("Adodb.command")
Conn. Open "Provider=Microsoft.Jet.OLEDB.4.0; Data source= "& Server.MapPath (" Db2.mdb ")

Cmd. ActiveConnection = conn
Cmd.commandtext = "SELECT * from people ORDER by id DESC"
Set rs = cmd. Execute

Do but not Rs. Eof
Response.Write RS ("id") & | "
Rs. MoveNext
Loop
%>

Http://www.cnbruce.com/test/getrows/show2.asp

Takes 2,187.500 milliseconds with a total test average of about 2 seconds
=========================================================
Neither of these can solve the problem of long execution time, the main reason is that the loop must be extracted to the database every time (command speed is relatively fast)
Then use the GetRows () method:
Copy Code code as follows:

<%
Set conn = Server.CreateObject ("ADODB. Connection ")
Set cmd = Server.CreateObject ("Adodb.command")

Conn. Open "Provider=Microsoft.Jet.OLEDB.4.0; Data source= "& Server.MapPath (" Db2.mdb ")
Cmd. ActiveConnection = conn
Cmd.commandtext = "SELECT * from people ORDER by id DESC"
Set rs = cmd. Execute
Rsarray = Rs. GetRows ()

For i = 0 to UBound (Rsarray, 2)
Response.Write Rsarray (0, i) & "| "
Next
%>

Http://www.cnbruce.com/test/getrows/show3.asp
Takes 187.500 milliseconds, the total test average is about 0.2 seconds
The GetRows () method copies the data from the Recordset into a two-dimensional array, which is a two-dimensional array, the first subscript identifies the field, and the second identifies the record number
So Rsarray = Rs. GetRows ()
Rsarray (0, 0) represents the first field value in the first row of the recordset
Rsarray (1, 0) represents the value of the second field in the first row of a recordset
The data for the array is stored in memory, which fundamentally solves the problem of requesting the database each time the record is displayed.

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.