Execution efficiency of ASP data extraction

Source: Internet
Author: User

Generally, data records are extracted from the database. You need to use SQL statements to query and obtain the relevant record set. Then, select related fields and related record rows from the record set for display.

In the process of extracting and displaying a series of columns, if you pay attention to the following points, the efficiency of data extraction is greatly increased.

1. specify the names of extracted fields.

Normal SQL statement extraction records are:
Select * from [data_table]
That is, the record values of all fields are extracted from data_table.

The execution efficiency of select * statements is very low, because two queries are actually executed when such statements are executed. Before the SELECT statement is executed, first, you must query the system table to determine the name and data type.

Therefore, use the select * Statement at least, and use a clear field name, such:
Select cn_name, cn_pwd from [data_table]
2. RS (0) is faster than Rs (filename ).
Set rs = conn. Execute ("select cn_name, cn_pwd from [data_table]")
In the record set RS (), you can enter the field name (numeric type) or the field index number (number), which indicates the first field in the field list. For example:
RS (0) indicates RS ("cn_name ")
RS (1) indicates RS ("cn_pwd ")

It has been proved that the number of indexes used to access the record set elements is several times faster than the field name. Query by string takes more time and system resources than query by integer.

3. assign a value to the variable before using the RS value of the record set.
<%
Set rs = conn. Execute ("select cn_name, cn_pwd from [data_table] Where cn_id = 1 ")
If not Rs. EOF then
Do while not Rs. EOF
Cn_name = RS (0) 'assigns the RS value to the variable
Cn_pwd = RS (1)
'... Use variable processing
Rs. movenext
Loop
End if
Rs. Close
Set rs = nothing
%>

However, when changing the display sequence of select list fields in SQL statements or stored procedures, you must pay attention to the assignment and processing.
4. Of course, using getrows () is another thing.

Contact Us

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.