Some unknown acceleration methods for ADO data operations!

Source: Internet
Author: User

Some unknown acceleration methods for ADO data operations!

The following are some of my frequently used methods that are rarely used. I will post them and share them with you. What do you want?

Do not be stingy with good methods. This post will be updated later

1. Optimization in the recordset loop,

Pre-initialization of fields will not bring about other code changes, which is very convenient, and the speed is also obvious in a large loop.

Dim R as new ADODB. recordset
Dim FLDS as ADODB. Fields
Dim II as long

'The loop method for next is not used here
'The recordcount is not supported for some record sets.

R. Open "select * from table", CN

'Here, preinitialize the fields object
Set FLDS = R. Fields
Do until R. EOF = true

'Each element of the Access Field
For II = 0 to FLDS. Count-1
Debug. Print FLDS (II). Value
Next
R. movenext
Loop

2. The fastest way to access field elements

FLDS (II). value. do not mean. value. You can use the index number when using the field index number.

3. Improve the search speed of find

The use of find must be used with the index. By default, find does not use the index and performs a row scan. The speed is of course extremely slow.

Cursorlocation = aduseclient the index can be used only when the client cursor is used
Key beginning
After opening the record set
Dim metadata as ADODB. Field
Set attributes = Rs. Fields ("jobcode") 'requires the field to be indexed
Criteria. properties ("optimize") = true
Find again, and you will find that the speed has increased by times.

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.