10W pieces of data available, the Access database is saved
By normal extraction:
The code copy is as follows:
<%
Setconn=Server.CreateObject("ADODB.Connection")
c&Server.MapPath("db2.mdb")
conn.Openconnstr
Setrs=Server.CreateObject("ADODB.Recordset")
sql="Select*frompeopleorderbyiddesc"
rs.Opensql,conn,1,1
DoWhileNotrs.EOF
Response.writers("id")&"|"
rs.MoveNext
Loop
%>
http://www.cnbruce.com/test/getrows/show1.asp
It takes 3,250.000 milliseconds, and the average total test value is about 3 seconds.
===============================================================================
Use stored procedure to extract:
The code copy is as follows:
<%
Setconn=Server.CreateObject("ADODB.Connection")
Setcmd=Server.CreateObject("ADODB.Command")
conn.Open"Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath("db2.mdb")
cmd.ActiveConnection=conn
cmd.CommandText="Select*frompeopleorderbyiddesc"
Setrs=cmd.Execute
DoWhileNotrs.EOF
Response.writers("id")&"|"
rs.MoveNext
Loop
%>
http://www.cnbruce.com/test/getrows/show2.asp
It took 2,187.500 milliseconds, and the average total test value was about 2 seconds.
==============================================================================
The above two cannot completely solve the problem of long execution time. The main reason is that the loop must extract records from the database every time (Command speed is relatively fast)
Then what about using GetRows() method:
The code copy is as follows:
<%
Setconn=Server.CreateObject("ADODB.Connection")
Setcmd=Server.CreateObject("ADODB.Command")
conn.Open"Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath("db2.mdb")
cmd.ActiveConnection=conn
cmd.CommandText="Select*frompeopleorderbyiddesc"
Setrs=cmd.Execute
rsArray=rs.GetRows()
Fori=0ToUBound(rsArray,2)
Response.WritersArray(0,i)&"|"
Next
%>
http://www.cnbruce.com/test/getrows/show3.asp
It took 187.500 milliseconds, and the total test average is about 0.2 seconds.
The GetRows() method is to copy data from the Recordset into a two-dimensional array. This is a two-dimensional array. The first subscript marks the field and the second marks the record number.
So rsArray=rs.GetRows()