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.