ASP itself is not a scripting language. It only provides an environment for scripting programs embedded in HTML pages to run. The most commonly used scripting language in ASP is VBScript. Although the scripting language of ASP is very simple, it is not easy to make an ASP program run optimally.
Nowadays, the network bandwidth in China is very limited and the network is very crowded. How to make your ASP application run quickly has become the dream of every ASP programmer. Then follow me to speed up your ASP program!
one. Optimization method for operating databases
The main purpose of our use of ASP is to operate the database. How to complete these actions more quickly?
1. Do not use "Select *..."
Please try to pick up the fields you need. For example, there are 10 fields in a Table, but you will only use one of them (name), and use "selectnamefromyourtable" instead of "select*fromyourtable". You might say, this is how I did it, but what would you do if there are 50 fields in a table and you need to use 23 of them? In order to save the trouble of typing and finding the corresponding field names, you may not be honest with the "selectname, sex, age...fromyourtable"!
Actually, trying to pick up the fields you need to use the select statement will be at least 5% faster for your ASP program.
2. Use system stored procedures whenever possible (for MSSQLServer)
Sometimes a read operation can be completed, using SQL statements and stored procedures, but using stored procedures will greatly speed up the read operation, which will increase the speed of your ASP program running.
3. Pay attention to how you use cursor
If you are just reading a table, please use forward-only, read-only cursors, because this cursor is the fastest to read the database, especially when you read a large amount of data.
4. Don't open useless standalone record sets
Maybe you are laughing, will I open a useless record set? Yes, of course, you will, for example, when generating a tree record set, you have to open the parent record set, the corresponding child record set, and even the grand record set. In fact, you can use the DataShaping technology provided by ADO to replace opening multiple independent record sets, which will speed up the program's running speed. (For the usage of DataShaping, please refer to the ADO Help)
5. Be sure to close open record set objects and connection objects
Some friends always wonder why their ASP program runs very fast at the beginning, but it becomes slower and slower after running it a few more times? The server crashes even. This happens, it is likely that you have opened too many recordset objects and Connection objects and finally not closed them. Use the following method to close: