Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
'SCAN FOR' vs 'LOCATE FOR'
Message
De
09/12/1999 22:51:39
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00301450
Message ID:
00301510
Vues:
30
>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
>
>The Locate For command is good to use when an index is not available. Given a large population of records, without an index, you really wont be able to speed things up....
>

Both are useful when you need some set of recors to be processed one at a time in the current order. LOCATE FOR's real playout is when you have some complex set of search requirements that are not in a single tag, but are all optimizable using the set of tags available for the table. SEEK works only if the filter condition matches the current tag expression. If taht's the case, SEEK and SCAN WHILE would seem to be a better tactic than LOCATE/CONTINUE.

If the sort order has nothing to do with eligibility of records, SEEK won't help. Neither will it help if several groups of records for the current tag order need to be examined.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform