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:
<%
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, not Rs. EOF
Response.Write RS ("id") & | "
Rs. MoveNext
Loop
%>
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.