Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Help Needed to Speed Up the code
Message
De
30/07/2013 10:49:21
 
 
À
30/07/2013 03:11:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01579372
Message ID:
01579418
Vues:
49
No sir, The Evaluation condition IF RECNO()%=0 is taking much more time as compared to my original code. I tested it 5 times on around 10000 records and fould that ech time it 30-35 seconds more. that may be perhaps of evaluating the IF condition each time.

Than I removed both i.e Wait wind and IF condition , than too I found that there was hardly a 10 sec difference

So i dont think that ,that issue is causing a huge delay



>>I am using the followin Scan Endscan loop to update the Target Path in a cursor.
>>But since my records are very huge, the processing is taking long-long times for updating.
>>
>>Can anybody give me equivalant SQL that can work faster.
>>
>>Here is my code
>>
>>
>>*This Program Will Update New_bill.dbf with New Target Path
>>SELECT New_bills
>>LOCATE
>>SCAN WHILE .NOT. EOF()
>>F=Filename
>>SELECT Master
>>LOCATE FOR accountno=F
>>IF FOUND()=.T.
>>E=ALLTRIM(Exchange)
>>ME=1 && Denotes that the exchgange is Not missing
>>ELSE
>>E="Missing Exchange"
>>ME=0 && Denotes that the exchange is Missing
>>ENDIF
>>
>>SELECT New_bills
>>P='&tDirectory'+'&pBillmonth'+'-'+ALLTRIM(STR(pbillyear))+'\'+E+'\'+STR(filename)+'.ps'
>>Replace Newpath WITH P
>>Replace Missexg WITH ME
>>Disp_percent=Alltrim(Str(Recno()/RecordsForSelectA*100))
>>Wait Wind "Step-3 [Updating Target Path Information..."+Disp_percent+"%"+" Completed]"  Nowait
>>ENDSCAN
>>RETURN
>>
>>
>>Thanks in anticipation
>
>Hi Harsh
>
>As Tamar outlined, in this particular case, you can get the same performance, more readability, and more flexibility, from VFP code without SQL
>
>this code should execute much faster - please read carefully the various comments inserted
>
>
>local llMaster
>Select New_bills
>Scan
>
>	llMaster = Seek(New_bills.Filename, 'Master', 'accountno') && assuming you have INDEX ON accountno TAG accountno
>	&& you can also SET RELATION TO Filename INTO Master IN New_bills - seek() will be done automatically
>	&& either way, you need an [INDEX ON accountno TAG accountno] to optimize (aka 'rushmorize') the relation between New_bills and Master tables
>
>	Replace ; && a single REPLACE is always faster than 2!
>		NewPath With ''; && It's always more explicit and safe to use a prefix (alias for fields, 'm' for variables)
>			 + m.tDirectory;
>			 + m.pBillmonth;
>			 + '-' + Alltrim(Str(m.pbillyear));
>			 + '\' + Iif(m.llMaster, Alltrim(Master.Exchange), "Missing Exchange");
>			 + '\' + Str(Filename);
>			 + '.ps';
>		MissExg With Iif(m.llMaster; && ME
>			, 1; && Denotes that the exchange is Not missing
>			, 0; && Denotes that the exchange is missing
>			)
>
>	if Recno()%100 = 0
>		Wait Wind ''; && this instruction is veeery time consuming - better execute it once in a while
>			+ "Step-3 [Updating Target Path Information...";
>			+ Alltrim(Str(Recno()/RecordsForSelectA*100));
>			+ "%";
>			+ " Completed]";
>			Nowait
>	endif
>Endscan
>Return
>
Harsh
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform