Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Which is faster?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00903686
Message ID:
00903688
Views:
24
Dawa,

I think the fastest would be following code because LOCATE is Rushmore optimizable with index set and GO BOTTOM is not. The separate SET order command doesn't move pointer to the first record also.
SELECT 0
USE mydb!table1  
SET ORDER TO field1 DESC
LOCATE
m.lnMax = table1.field1
USE IN table1
>
>I have a table with an integer field indexed ascending. To retrieve the maximum value of that field, which is the faster approach below:
>
>Approach 1:
>
>USE mydb!table1 IN 0 ORDER field1
>GO BOTTOM
>m.lnMax = table1.field1
>USE IN table1
>
>
>Approach 2:
>
>USE mydb!table1 IN 0 ORDER field1
>CALCULATE MAX(table1.field1) TO m.lnMax
>USE IN table1
>
>
>If one is faster the other, then why?
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform