Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
It has been proved that accessing a recordset element by index number is more than a few times faster than the field name. Querying by strings takes more time and system resources than an integer query.
Therefore, you should be aware of the following two issues when traversing a database:
1. Use of statements of SELECT * as least as possible
When you traverse a small number of fields in a table, the SELECT * statement is inefficient, because the execution of such a statement in fact executes two queries, before executing a SELECT statement, you must first query the system table to determine the name and data type.
2. Before using the recordset RS value, you should assign it to a local variable.
This is especially true for manipulating text/memo fields.
I have found that a local variable in "read mode" is slightly faster than a new call to Rs value from a Recordset, especially when recall a recordset more than once.
Let's look at an example of an asp:
' Create a database connection.
Set rs = Conn.execute ("exec sp_getrecords")
If not rs.eof then
Do as not rs.eof
id = rs (0) ' assigns the RS value to the local variable
fname = RS (1)
LName = RS (2)
' ... Working with local variables
' ... Release the variable and end the connection.
Finally, note that if you change the order of the select list in an SQL statement or stored procedure, pay special attention when assigning values.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.