Test the speed of extracting 0.1 million pieces of data using stored procedures, GetRows (), and

Source: Internet
Author: User

Existing 10 million data records, stored in the Access Database

Normal extraction:Copy codeThe Code is 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 While Not rs. EOF
Response. write rs ("id") & "|"
Rs. MoveNext
Loop
%>

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

It takes 3,250.000 milliseconds, and the total test average is about 3 seconds.
========================================================== ============================

Use Stored Procedure extraction:Copy codeThe Code is 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 While Not rs. EOF
Response. write rs ("id") & "|"
Rs. MoveNext
Loop
%>

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

It takes 2,187.500 milliseconds, and the total test average is about 2 seconds.
========================================================== ========================
The preceding two methods cannot completely solve the problem of long execution time. The main reason is that each cycle must extract records from the database (the Command speed is relatively fast)
Use the GetRows () method:Copy codeThe Code is 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
It takes 187.500 milliseconds, and the total test average is about 0.2 seconds.
The GetRows () method copies data from Recordset to a two-dimensional array. This 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) indicates the first field value in the first row of the record set.
RsArray (1, 0) indicates the second field value in the first row of the record set.
The array data is stored in the memory, which fundamentally solves the problem that each display record still needs to request from the database.

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.