Thanks Sorin for the reply,
I am definitely not using Approach 2. As for 1, I still wait and see.
Dawa
>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
Dawa Tsering
"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."
- Ephesians 4:29-30 NIV
Dare to Question -- Care to Answer
Time is like water in a sponge, as long as you are willing you can always squeeze some.
--Lu Xun, Father of Modern Chinese Literature