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:
00903751
Views:
13
Approach 1 is definitely faster. And it is probably the fastest in your case using the index on the interger field.
Approach 2 must go through every record and calculate the max before it can return a result. Approach 1 would simply read the last record in the index, go to it and retrieve the value from the table.


>Hi All,
>
>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?
>
>Any response will be appreciated greatly!
>
>Dawa
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform