Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
REPLACE Statement Efficiency
Message
De
23/06/2000 18:51:41
 
 
À
23/06/2000 18:27:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00384060
Message ID:
00384127
Vues:
33
>>The first one is better time-wise because it does it once. It's especially noticable with REPLACE ALL.
>>
>
>Hey Michelle,
>
>I know that if I used the second syntax with a REPLACE ALL VFP would take three trips through the database, but I'm curious as to whether internally VFP effectively converts the first form to three separate REPLACEs. The record is afterall in memory. The REPLACE statement should not actually generate any I/O until you move off the record right?
>
> ...kt
>>
>>
>>>Generally speaking, is it more efficient to do something like
>>>
>>>REPLACE X WITH 1, Y WITH 2, Z WITH 3
>>>
>>>than
>>>
>>>REPLACE X WITH 1
>>>REPLACE Y WITH 2
>>>REPLACE Z WITH 3
>>>
>>>My suspicion is that the two are equivalent, but if anyone has different information, please share.
>>>
>>>Thanks,
>>>
>>> ...kt

I don't know exactly what is happening internally, but replace x with 1, y with 2, z with 3 is DEFINITELY faster than three separate replace statements -- even in a single record. This is because VFP NEVER takes three statments and combines them into 1. In other words three statements get compiled into three lines of code, one statment into one.


Tell you sometyhing really weird thought
The following codes
go top
scan
REPL x with 1,y with 2, z with 3
endscan

runs faster than:
REPL ALL x with 1, y with 2, z with 3.

This is documented in the hackers guide and I have tested it myself.
Thanks

Gar W. Lipow
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform