>Gene Wirchenko seemed to utter in news:gvmc74pmf77dfqlg9ul1jnn3ueevnh20u5@
>4ax.com:
[quoted text clipped - 10 lines]
>>
>> The second way goes through the table once.
>But with an index on the column used in the FOR condition,
>it will just use the index to go directly to the
>correct records. It shouldn't scan the entire table for
Which correct records? Your code touches EVERY one of them.
>each REPLACE. And the SCAN calls the function 50K times!
>This is a pretty streamlined function, but I would think
>that the SCAN would *at best* take a little longer than
>the REPLACE FOR approach. Yet it's 5 times faster!
First scan. All of the values that occur are extracted.
Second to n+1 scans. Each of the values is processed. There are
quite possibly multiple occurrences of value.
Since every value that occurs is processed, EVERY row is going to
be processed.
Which do you think is the more efficient way to process?
1) n passes through the data (using indexes or not)
2) one pass through the data
Note that processing a file sequentially is faster than
processing the same file in index order. The sequential access does
not have jumping about. The indexed access may have a lot; at best,
it will be the same as sequential (and that is unlikely to occur).
>I wonder if some strange RUSHMORE optimization is happening
>that is taking extra time to setup and not paying back in
>speedier REPLACEments.
Nope. You are doing a pessisimisation by separating out the
processing for each value into a pass.
It does depend on what .Standardize() does. If it is slow, then
your organisation of code could work. If it is not, then the time it
takes to repeatedly execute is drowned out by the disk I/O. It would
take a rather time-consuming method for it to not be drowned out by
disk I/O.
Even if .Standardize() were somewhat slow, one could use caching
of the results. Primary memory access is faster than secondary memory
access.
A final note: curval is a resrved word, so you should use
something else.
Sincerely,
Gene Wirchenko
Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.