Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which command would execute faster? Seek & Do while or S
Message
De
27/03/2006 23:12:53
 
 
À
27/03/2006 22:51:59
Sonny Tabano
Trams Printwork, Inc.
Mabalacat, Philippines
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01108228
Message ID:
01108231
Vues:
11
Option 1 will not be the fastest. This will be faster than option 1 (no macro expansion and SCAN WHILE). However, your network speed could have an affect on which is faster. I would go with option 2.
Local lnTotalOrder, lcCustID

lnTotalOrder = 0
lcCustID = "0008"

Seek lcCustID    && Seek "0008"
SCAN while Customer.Cust_ID=lcCustID
   lnTotalOrder = lnTotalOrder + Customer.OrderAmount
EndSCAN
Return (lnTotalOrder)
>Hi everyone,
>
>Which of the commands below would execute faster assuming you have a million records and 200,000 of this records corresponds to the CUST_ID to compute the OrderAmount?
>
>1. (PRG)
>
>Local lnTotalOrder, lcCustID
>
>lnTotalOrder = 0
>lcCustID = "0008"
>
>Seek &lcCustID    && Seek "0008"
>Do while Customer.Cust_ID=&lcCustID
>   lnTotalOrder = lnTotalOrder + Customer.OrderAmount
>   Skip
>Enddo
>Return (lnTotalOrder)
>
>
>or
>
>2. (SQL)
>
>Select Customer.Cust_ID, sum(Customer.OrderAmount) As lnTotalOrder;
>from Customer  into cursor temp where Customer.Cust_ID="0008" Group by Customer.Cust_ID
>
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform