devxlogo

LOCATE versus GO TOP

LOCATE versus GO TOP

Question:
Which is faster, LOCATE (without parameters) or GO TOP? How fast is the one from the other? Why is one faster than the other?

Answer:
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.

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist