Which is faster, LOCATE (without parameters) or GO TOP? How fast is the one from the other? Why is one faster than the other?
They are usually equal except under one circumstance: when an index is active. LOCATE is Rushmore-Optimized and therefore can take advantage of the current index.
LOCATE performs a serial search: it starts from the top of a table and goes record by record until it finds one that matches the logical expression. For example, LOCATE FOR cName=”Rick” will go to the top of the table and go record by record until the logical expression cName=”Rick” resolves to .T.. Executing a LOCATE without any parameters is the equivalent of the following command:
LOCATE FOR .T.
LOCATE goes to the top of the index in memory and evaluates the logical condition (.T.), which of course resolves to .T., so the first record meets the logical condition.