Almost all articles about the ADO database access performance analysis, it is considered that the performance of binary components always exceeds the ASP code executed. In fact, this is wrong. As can be seen from the test results of this article, sometimes the performance of the ASP code far exceeds the component.
I. Introduction
"The earth is flat ...";
"The sun turns around the earth ...";
"Always access databases through components ..."
There are two common features above three propositions: First, they have been considered correct; secondly, these three propositions are actually wrong.
We have already read countless articles. It is recommended to use component package business logic and database access in Internet applications, but the actual performance data of this technology is rarely seen. With the distribution of Windows 2000, the performance performance of IIS platforms, especially ASPs has also improved significantly. Due to the multi-Binding internal objects, template buffers, etc., ASP has first-class performance performance through ADO access database, format and outputs record sets through ADO.
As can be seen from this test results, ASP is better than component in ADO database, and the difference in the formatting in some cases has reached an incredible degree of incredibility. For most Internet applications, performance is always a primary factor, so it is important to use testing tools to perform testing of the program for complete testing of the program before the optimal programs are determined according to rumors or book knowledge.
All three sets of code (ASP, VB, and C ) of this article were optimized before testing. In order to ensure that the code in which the test is involved, its coding method and test results are the best in their respective fields, they have been tested multiple times. Some optimization work has not been conducted, which is to make the code more truly reflect typical situations in the actual application environment.
Second, the test environment
This test is only performed on the Windows 2000 platform, and the test results on the Windows NT platform may be large, so the results obtained from the test do not apply to the Windows NT platform. Below is a schematic diagram of the system used in this test and its description:
Due to test clients and web servers, the physical location of the database server is different, and the client is connected to the web server through three Cisco 2924 switches. All of these machines are in the same building, but the server is located in the data center, and the test client is located in another room, and the client is connected to the data center through a 400MB Fast EtherChannel connection.
Under this configuration, the overhead caused by the network delay of the test case is very small. The traffic between the switches between the daily operations is always less than 5% of its capabilities.
Third, test code
Since this is a test from the ASP, VB components, C components through ADO, the function of test code is limited to creating a form from the result recordset. All test programs can be downloaded from this article. The execution flow of these programs is similar, as follows:
Create / open a database connection with ODBC DSN
Create a Command object (set its type to adcmdstoreProc)
Specify parameters of the number of records returned
Execute command, return to record set
Turn off the record set and connection, release the memory occupied by these objects.
It can be confirmed that the above method has the fastest database access speed because:
Storage procedure access speed is fast than dynamic SQL, even if the SQL scheduled cache function of SQLServer 7.0 is enabled.
Use the Command object and explicitly specify the parameter to be much faster than the incoming query string, because the OLEDB provider does not need to analyze the type of query and all the types of parameters passed to the stored procedure.
The ODBC connection pool avoids creation of physical connections for each open command. Each closing connection will release the open connection back to the connection pool.
Structure, this is to allow test programs to simulate the actual recordset processing process more accurately.
The HTML code returned to the client is the