Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
'SCAN FOR' vs 'LOCATE FOR'
Message
From
09/12/1999 22:35:54
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00301450
Message ID:
00301503
Views:
28
>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
Map
View

Click here to load this message in the networking platform