Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scatter with memo
Message
De
03/06/2003 12:40:19
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
03/06/2003 12:21:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00795601
Message ID:
00795769
Vues:
21
>>>
>>No chance for me to know how VFP team designed that but I trust them :)
>>Below is a very simple test (very simple in that it can't be a reason to solidly say append from is better) :
>>
>
>Ahhh....I see what you're saying. I had a different scenario in mind.
>
>My point is that if this function is going to be called multiple times in a row, APPEND FROM is not effective. For example, assume there is a list of items that need to be archived.
>
>It is not clear this thread whether Steve will call his routine multiple times in a row.
>
>
>create cursor recordsToProcess (myPK i)
>rand(-1)
>for i = 1 to 10
>    * hope we don't get lucky and create a duplicate :)
>	insert into recordsToProcess values (rand()*500000)
>next i	
>
>Create Cursor myTest1 (myPk i, myVal c(10))
>For ix=1 to 1000000
> Insert into mytest1 values (ix, Sys(2015))
>endfor
>Index On myPK tag myPK
>
>AFields(arrNew)
>Create Cursor myTest2 from array arrNew
>Create Cursor myTest3 from array arrNew
>
>
>lnStart = Seconds()
>Select recordsToProcess
>scan
>	select myTest1
>	scan for myTest1.mypk = recordsToProcess.mypk
>		 Scatter memvar
>		 Insert into myTest2 from memvar
>	endscan
>
>endscan
>? Seconds()-lnStart
>
>
>lnStart = Seconds()
>Select recordsToProcess
>scan
>	select myTest3
>	Append From Dbf('myTest1') for myPK = recordsToProcess.myPk
>endscan
>? Seconds()-lnStart
>
Who knows maybe I'd change the above code slightly to get all into an SQL cursor first and do a single append (no for), or create an index for recordstoProcess.myPk and drop scan again ( append .. for seek(myPk,'recordsToProcess','key') ), or copy to array, insert from array in blocks etc (last one is an exceptionaly fast method but coding generally complex)

Operations like this can be done in multiple ways in VFP and I choose the strategy based on what'd I do, loop needed or not etc. Sometimes I even choose a slightly slower one for sake of readability or go writing into C dlls that directly write to table :)

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform