Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual FoxPro
Expertise: Beginner
Oct 16, 2000

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.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap