Two ways and comparisons for storage process calls in ASP

zhaozj2021-02-16  76

Write a simple message with SQL Server and ASP, discovering in a constant attempt, when the page is displayed, different execution methods, some differences in time.

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 = conn

Cmd.commandtext = "ycuu_gb_getmsg"

Cmd.commandtype = 4'adcmdstoredProc

cmd.prepared = True '

Set param = cmd.createParameter ("@ ipageno", Adinteger, 1, 2, Page)

Cmd.parameters.Append param

Set param = cmd.createParameter ("@ ingagesize", Adinteger, 1, 2, PageSizeConst)

Cmd.parameters.Append param

SET RS = 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 make the function of DODB.Recordset, the specific code is as follows:

SET RS = Server.createObject ("AdoDb.Recordset")

SQL = "SELECT * from Guestbook ORDER BY DATEANDTIME DESC"

RS.Open SQL, CONN, 1, 1

rs.pageSize = 150 'The number of messages displayed per page,

Total = rs.Recordcount

mypagesize = rs.pageSize

rs.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:

Discover, 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: stabilize .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.

The way the former's call 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.

转载请注明原文地址:https://www.9cbs.com/read-16399.html

New Post(0)