I have written a simple message with SQL Server and ASP. In the constant attempt, discover that the page is displayed, and some differences are different.
The following is compared to the time comparison of several ways.
First, use the stored procedure paging, this situation is divided into two ways:
The first, use the Command object, as follows:
Set Cmd = server.CreateObject ( "Adodb.Command") Cmd.ActiveConnection = connCmd.CommandText = "ycuu_gb_getmsg" Cmd.CommandType = 4'adCmdStoredProccmd.prepared = true'set param = Cmd.CreateParameter ( "@ iPageNo", adInteger, 1, 2, page) cmd.Parameters.Append paramset param = cmd.createParameter ("@ ipageSize", adINteger, 1, 2, pagesizeconst) cmd.parameters.Append paramset = cmd.execute
Second, execute it directly using the implementation method of the Connection object, as follows:
SET RS = Conn.execute ("Execute Ycuu_GB_GETMSG" & Page & "," & PagesizeConst)
Second, do not use the stored procedure, directly using the features of AdoDb.Recordset, the specific code is as follows:
SET RS = Server.createObject ("AdoDb.Recordset") SQL = "Select * from guestbook order by dateandtime desc" rsopen sql, conn, 1 ,1rs.pageSize = 150 'per page display number, total = rs .Recordcountmypagesize = rs.pagesizers.absolutepage = PAGE
In order to display the speed more, I increase the number of messages displayed per page to 150 (in fact, there is certainly won't set such a big value). As for the configuration of my machine, I will not say that it is mainly compared.
Discover, the time of execution is as follows:
The first one: stabilizes between 0.1953125 seconds to 0.210,9375 seconds, the average value is: 0.20 seconds
The second: stabilizes between 0.1716875 seconds to 0.1857 seconds, the average value is: 0.177 seconds
The third: stabilizes between 0.4375 seconds to 0.4632 seconds, the average value is: 0.45 seconds
However, when the number of records read is 20, the results are as follows: found that the time of execution is as follows:
The first one: stabilizes .0390625 seconds to .0546875 seconds, the average value is probably: 0.045 seconds
Second: Stable between 0.046875 seconds to .0546875 seconds, the average value is probably: 0.050 seconds
The third: stabilizes between .09375 seconds to 0.1015625 seconds, the average value is probably: 0.97 seconds, it seems that conn.execute and command.execute seems to be different, and the former call mode It seems to be more simple. At the same time, it can be seen here that the speed of storage process of paging is indeed a lot more faster than the Paging speed of Recordset.
PS: The younger brother issued a text, hey, I found a good hard, I will work hard. I hope that everyone will bear to write bad this time. By the way, I still want to ask you Heroes CONN.EXECUTE and COMMAND.EXECUTE these two ways in these two ways, huh, because I found the latter in this way to perform stored procedures. I don't know why I don't need to be as simple as in front.