" & objrs ("freight") & " td>" & _
Tr> "_
)
Objrs.movenext
Loop
Response.write (" Table>")
END IF
Objrs.close
Objconn.close
Set objrs = Nothing
Set objconn = NothingResponse.write (" body> html>")
%>
The result is this:
Let's first take a look at what the numbers in each column are:
0 The representative runs the TTLB when returning 0 records, unit milliseconds. In all we test, this number is used to log the page's load or load page to create objects but not in the data cycle.
25 Load and display 25 recorded TTLB (ms).
Tot Time / 25 TTLB is divided by 25 records (ms). Represents the total average time of each record.
The DISP TIME / 25 subtracts the TTLB of the "0" in the TTLB of milliseconds, and divides 25 records. Represents the time of each record in the recordset cycle.
250 Load and display 250 recorded TTLB (ms).
TOT TIME / 250 TTLB divided by 250 records (ms). Represents the total average time of each record.
The DISP TIME / 250 subtracts the TTLB of the "0" in the TTLB of milliseconds, and divides 250 records. Represents the time of each record in the recordset cycle.
We will compare these values with the results below.
Should I use the adovbs.inc containing files? I want to solve this problem. The Adovbs.inc file provided by Microsoft contains 270 line code that represents most of the constants that can be applied to the ADO properties. In our example, only 2 of this file in this file. So for this test (ADO__02.asp), I canceled the reference to the file, and the actual number in the attribute list is used instead of constants.
Objrs.cursortype = 0 'AdopenForwardonly
Objrs.lockType = 1 'AdlockReadOnly
We can see that the load time is reduced by 23%. This is different from the display time of each record, as this change should not have an impact on the recording concentration cycle. There are several solutions to this issue. I recommend using the adovbs.inc file as a reference, if necessary, use the annotation to indicate the number. To remember, just like in the first part, the annotation does not require fear, because as long as the mode is moderate, they do not have a big impact on performance. Another way is to copy only the constant you need from the file to the page.
Solving this problem has a cool way to connect all ADO constants to your application by connecting the ADO class library to your application. Add the following code to your global.asa file, you can use all constants directly.
File = "C: / Program files / compon files / system / ado / msado15.dll"
Name = "AdoDb Type Library" ->
or
UUID = "00000205-0000-0010-8000-00Aa006d2ea4"
Name = "AdoDb Type Library" ->
So, here is our first rule:
* Avoid including an adovbs.inc file, use constants with other methods.
When using a recordset, should a separate Connection object? If you want to answer this question correctly, you need to verify the test results in two different situations: The first is to perform a database processing per page, the second is Pages perform multiple database processing.
In the previous example, we have created a separate connection object and passed it to the ActiveConnection property of the recordset. However, it is also possible to only pass the connection string to this property, so that an additional step is to be avoided, that is, a separate component is illustrated and configured in the script (ADO__03.asp): objrs.activeConnection = Application ("conn")
Although we still created a connection in the recordset, it was created with very optimized, so we saw that the startup time was reduced by 23% higher than the previous test, as expected, each There is little difference in the display time of the record.
Therefore, our second rules are:
* When a single recordset is used, the connection string is passed to the ActiveConnection property.
Below you want to determine if multiple record sets are created on a page, this logic is still established. To test this situation, I introduced the For loop and repeated the previous example 10 times. In this test, we will also study 3 choices:
First, we created and destroy the Connection object in each loop (ADO__04.ASP):
DIM I
FOR i = 1 to 10
Set objconn = server.createObject ("adoDb.connection")
Objconn.open Application ("conn")
Set objrs = server.createObject ("adoDb.recordset")
Objrs.activeConnection = Objconn
Objrs.cursortype = 0 'AdopenForwardonly
Objrs.lockType = 1 'AdlockReadOnly
Objrs.open Application ("SQL")
IF objrs.eof kil
Response.write ("No Records Found")
Else
'Write Headings
...
'Write Data
...
END IF
Objrs.close
Set objrs = Nothing
Objconn.close
Set objconn = Nothing
NEXT
Second, create a separate Connection object in the loop and share it with each recordset (ADO__05.ASP):
Set objconn = server.createObject ("adoDb.connection")
Objconn.open Application ("conn")
DIM I
FOR i = 1 to 10
Set objrs = server.createObject ("adoDb.recordset")
Objrs.activeConnection = Objconn
Objrs.cursortype = 0 'AdopenForwardonly
Objrs.lockType = 1 'AdlockReadOnly
Objrs.open Application ("SQL")
IF objrs.eof kil
Response.write ("No Records Found")
Else
'Write Headings
...
'Write Data
...
END IF
Objrs.closset objrs = Nothing
NEXT
Objconn.close
Set objconn = Nothing
Third, pass the connection string to the ActiveConnection property (ADO__06.ASP) in each loop:
DIM I
FOR i = 1 to 10
Set objrs = server.createObject ("adoDb.recordset")
Objrs.activeConnection = Application ("conn")
Objrs.cursortype = 0 'AdopenForwardonly
Objrs.lockType = 1 'AdlockReadOnly
Objrs.open Application ("SQL")
IF objrs.eof kil
Response.write ("No Records Found")
Else
'Write Headings
...
'Write Data
...
END IF
Objrs.close
Set objrs = Nothing
NEXT
You may have guessed that it is a low-efficiency method to create and destroy the Connection object in each loop. But amazing is that only the efficiency of transmitting the connection string in each cycle is only a little bit lower than the efficiency of the shared single.
Despite this, our third rules are:
* When using multiple record sets on a page, create a Connection object and reuse it in the ActiveConnection property.
In the type of pointers and locks, which is the most effective? So far, all of our tests use only a pointer for forward only in the recordset. However, ADO also provides three types of pointers for records: Static, Dynamic, and KeySet (keyboard). Each provides additional functions, such as moving and backward movement, and when others are established, you can see the modified function. However, the connotation of these pointer types is not the scope discussed herein. I left these to you. Below is a comparative analysis of various types.
These additional pointers have significantly caused a larger load (ADO__03.asp) compared to their similar Forward Only. In addition, these pointers are slower during cycle. I want to share with you to avoid this idea: "I need a Dynamic pointer from time to time, so simply use it."
In essence, the same problem is also applicable to the type of lock. Only the READ ONLY type lock is only used in the previous test. However, there are three types of locks: Lock Pessimistic, Lock Optimistic and Lock Batch Optimistic. Like the choice of pointers, these locks also provide additional functions and controls for data in the processing record set. Similarly, I will give you myself for you to learn the appropriate use of each lock setting.
So guiding us to consider the logic of rule 4 very simple: using the simplest pointer and lock of the task that best suits you.
What is the best way to get a record set? So far, we just recover records through the Recordset object. But ADO also provides some indirect methods for acquiring records. The next test compares the values in the ADO__03.asp to create a recordset object directly from a Connection object (conn_01.asp).
Set objconn = server.createObject ("adoDb.connection") Objconn.open Application ("conn")
Set objrs = Objconn.execute (Application ("SQL"))
We see that there is a slight increase in the load that shows that the time of each record has not changed.
Then, let's take a look at a RecordSet object directly from a Command object (CMD__01.asp):
Set objcmd = server.createObject ("adoDb.command")
Objcmd.activeConnection = Application ("conn")
Objcmd.commandtext = Application ("SQL")
Set objrs = Objcmd.execute
We once again see a slight increase in the load, and the display time of each record has a nominal difference. Although the last two methods have little effect on performance, there is a big problem that needs to be considered.
Creating a recordset via the Recordset class For control how to handle the record set provides maximum flexibility. Although other methods have not proposed an overwhelming performance problem, you will be confused by the default states and lock types, which are not necessarily optimal for your specific needs.
So, unless you need other methods because of some special reason you need other methods: Examples of the record set to get the best performance and maximum flexibility through the AdoDb.Recordset class.
Should I disconnect the record? ADO provides a selection for disconnecting a recordset, and the recording set will resume all data in a forward query, turn off the connection, and use a local (or customer) pointer to move in the data set. This also provides an opportunity for an early release connection. This situation is necessary for processing remote data services, because the data must be disconnected from the database. But is it good for ordinary uses?
Below we add the CursorLocation property, turn off the connection after opening the record set (Client1.asp):
Set objrs = server.createObject ("adoDb.recordset")
Objrs.cursorLocation = 3 'aduseclient
Objrs.activeConnection = Application ("conn")
Objrs.lockType = 1 'AdlockReadOnly
Objrs.open Application ("SQL")
Objrs.activeConnection = Nothing
In theory, this technology should lead to faster performance. There are two reasons: First, when moving in the recordset, avoiding the repeated request by the connection; secondly cancel the connection to reduce the resource requirements. However, when using the client pointer, the efficiency is low. May be due to the use of the customer pointer position, no matter what your settings, Cursortype is modified to static.
Rules 6 is this: unless it is required in an open environment, avoiding disconnects.
What is the best way to set up recordset properties? All of the previous tests are set directly to the properties of the record set through separate attribute settings. But the RecordSet.open function can receive additional parameters for all properties we need. Although for each attribute, separate code lines are readily read and maintained, they still have to perform a single function call, must be set through the COM interface (ADO__07.asp): set objrs = server.createObject ("adoDb.recordset ")
Objrs.open Application ("SQL"), Application ("Conn"), 0, 1
'Adforwardonly, AdlockReadonly
These methods have brought the difference in the load, so we get rules 7: Do not worry about the set record set attributes separately
What is the most effective way to reference record concentration domain values? So far, I use the name of the recordset in the name of the name. This may be a very low efficiency, because each call requires a field. To prove this, the following test is to reference the domain by recording a set of sets of concentrated domains (ADO__08.ASP):
'Write Data
Do While Not Objrs.eof
Response.write (_
|