General information
Category:
Coding, syntax & commands
>Hi Chris...
>
>As everyone has pointed out, these commands are rushmore optimizable. However, that isn't the real key to the speed. First off, the FOR operator will evaluate ALL records. Instead, it is much faster to use a combination of Seek and Locate.
>
>For example, lets say you wanted to loop through the records where state = "PA". Something like this would be much faster:
>
>Select customers
>If Seek("PA","customers","state")
> Scan While State = "PA"
> */ Do your stuff
> EndScan
>Endif
>
I am confused here John... and if you have some inside info please share it... but, if there is an index on STATE what does the foxpro engine do different for...
SEEK('PA')
or
LOCATE for STATE='PA'
Seems to me it (the VFP Engine) still has to read the index to determine where the first value of PA is. The only small overhead I see with LOCATE is it has to decide which index to use as opposed to being told.
Unless you are saying that SEEK DOES Sometype of hashing or some type of index magic that LOCATE doesn't do.
I would even guess (no treu knowledge here) that there is a function like FindValueInIndex() that both locate and seek use. Locate just does a bit of stuff first to see which index to use, which takes how long?
Have you benchmarked the speed of Seek Vs Locate? Thanks for providing technical specifics that prove seek is 'MUCH Faster' than Locate.
BOb
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only