*whoisfaster.prg CLEAR DELETE FILE table1.* CREATE TABLE table1 FREE (field1 I) INDEX ON field1 TAG field1 OF table1.CDX ASCENDING LOCAL lcCaption m.lcCaption = _VFP.CAPTION FOR i = 1 TO 2^13 _VFP.CAPTION = TRANSFORM(i) INSERT INTO table1 VALUES (RAND()*1000000000) NEXT _VFP.CAPTION = m.lcCaption USE IN table1 LOCAL lnCount m.lnCount = 2^10 release all except lnCount * *** clear unused buffers SYS(1104) *Approach 1 LOCAL lnSeconds m.lnSeconds = SECONDS() FOR i = 1 TO m.lnCount =approach1() NEXT ?"Approach 1" ?SECONDS() - m.lnSeconds * Result: *Approach 1 * 0.406 release all except lnCount * *** clear unused buffers SYS(1104) *Approach 2 m.lnSeconds = SECONDS() FOR i = 1 TO m.lnCount =approach2() NEXT ?"Approach 2" ?SECONDS() - m.lnSeconds * Result: *Approach 2 * 0.422 release all except lnCount * *** clear unused buffers SYS(1104) *Approach 3 m.lnSeconds = SECONDS() FOR i = 1 TO m.lnCount *10 && m.lnCount I had to change this to much smaller because it took too long =Approach3() NEXT ?"Approach 3" ?SECONDS() - m.lnSeconds * Result: *Approach 3 * 18.297 DELETE FILE table1.* FUNCTION approach1 LOCAL lnMax USE table1 * ORDER field1 set order to field1 GO BOTTOM m.lnMax = table1.field1 USE IN table1 RETURN m.lnMax ENDFUNC && approach1 FUNCTION approach2 LOCAL lnMax USE table1 SET ORDER TO field1 DESC LOCATE m.lnMax = table1.field1 USE IN table1 RETURN m.lnMax ENDFUNC && approach2 FUNCTION approach3 LOCAL ARRAY lnMax(1) USE table1 SET ORDER TO field1 DESC SELECT TOP 1 field1 FROM table1 ORDER BY field1 DESC INTO ARRAY lnMax USE IN table1 RETURN m.lnMax(1) ENDFUNC && approach3