![]() |
|
|
Published: Wednesday, December 08, 1999 Set Statement
By Mike Shaffer
In an earlier article on 4Guys (Optimizing ADO Calls), I detailed
a method of using ordinal references to particular columns in a
If you refer to recordset values in your code quite a bit (and most of us do), there is a way to improve performance tremendously with very little effort. Here's the secret: when referring to recordset elements, use the ordinal form. This removes the requirement for a pseudo-dictionary lookup on the fieldname. That would mean our sample above would look like this (assuming that the field
(Note: I recommend using a Yet another method of referring to recordset fields is available. This method is probably the most powerful when it comes to optimizing for speed with larger recordsets. By SETting a variable to a field reference, you avoid a table lookup and separate assignment operation altogether. For example, consider this (pseudo-)code based on our examples above:
Notice that we only have to do the assignment once for
Since
To learn more about the Here are some sample benchmarks for three runs using each method (not done under a controlled environment, but close enough to prove the point!):
From the impromptu benchmarks above, you can see that the method 1 (which I find most people currently using) is the slowest. Method 2 is a very nice alternative, especially for pople who want a 'quick fix' for existing code without having to make many changes. Method 3, obviously the best in terms of execution speed, is very well suited to any of your new development. Overall, method 3 is a very good technique for you to keep in your arsenal. Happy Programming!
Related Articles:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||