The speed test of 100,000 data extracted by ASP three methods

Source: Internet
Author: User
Tags array db2 first row access database
Data | Speed

Existing 10W data, Access database save

Through normal extraction:

<%
Set conn= Server.CreateObject ("ADODB.") Connection ")
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &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
%>

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

Using Stored procedure extraction:

<%
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
%>

  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:

&lt;%


Set conn = Server.CreateObject ("ADODB. Connection ")


Set cmd = Server.CreateObject ("Adodb.command")


Conn. Open "Provider=Microsoft.Jet.OLEDB.4.0; Data source= "&amp; Server.MapPath (" Db2.mdb ")





cmd. ActiveConnection = conn


cmd.commandtext = "SELECT * from people ORDER by id DESC"


Set rs = cmd. Execute





do, not Rs. EOF


Response.Write RS ("id") &amp; | "


Rs. MoveNext


Loop


%&gt;

  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.







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.