Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Which command would execute faster? Seek & Do while or S
Message
From
29/03/2006 13:59:58
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
29/03/2006 13:17:55
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01108228
Message ID:
01108923
Views:
20
>>>SUM WHILE is much better than a SUM FOR whether you have a compound expression or not. IOW if you have
>>>
SET ORDER TO Cust_ID
>>>SEEK m.lcCustID
>>>SUM WHILE
>>>
>>>that will easily beat
>>>
>>>
SET ORDER TO 0
>>>SUM FOR Cust_ID = m.lcCustID
>>>
>>>Especially as the number of records increases.
>>>
>>I created a table with 8 million records and 4 fields (I1, I2, D1, C1). I1 was populated with INT(recno()/10000). C1 was populated with PADL(1+mod(recno()),4,"0")
>>
>>cc = "0008"
>>
>>SET ORDER TO 0
>>n1 = SECONDS()
>>SUM I1 TO abc FOR c1 = m.cc
>>? SECONDS() - n1
>>
>>SET ORDER TO 1
>>n1 = SECONDS()
>>SEEK m.cc
>>SUM I1 TO abc WHILE c1 = m.cc
>>? SECONDS() - n1
>>
>>
>>The results were equivalent, with the first one seeming to be marginally faster. Strangely enough, I appeared to get best results using SUM FOR when ORDER was set to 1.
>>
>>This was in VFP 6.
>>I'ld be interested in a similar comparison in VFP 9.
>
>The database engine itself is practically the same, so the results would probably be similar. Anyway, the conclusion I have reached many years ago, is that as long as you have the necessary ndexes, all the different approaches will give more or less the same results. Unless you have a really huge amount of data, and a lot of processing, you should use the approach which you find easiest in the specific situation. I have seen too many people who have used days to try to save a few milliseconds. VFP rocks!

A 4 cylinder engine is similar to an 8 cylinder engine. Both would get to the corner store at about the same time as the speed limit is the bottle neck. However, when there is no bottle neck and there is no worry about gas prices or pollution, I'll take the 8 cylinder knowing it is more powerful.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform