Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Speeding up search - Locate For or Seek?
Message
 
To
26/07/2000 10:50:58
Erin Eby
Mission Critical Software
Gainesville, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00397065
Message ID:
00397074
Views:
16
>Hi there! I am a reletively new FoxPro user and I had a question concerning searching a table. I am currently using Locate for's to search for my results, but I have been told that seek is quite faster. Is there something faster than seek? And can anyone explain in a nutshell what makes one faster than the other? Also, I already have a ton of indexes on the table too. Thanks for any answers you all can give me! :)

Erin,

LOCATE is a sequential search of the table. SEEK utilizes indexes which are binary trees ordering the table. There is nothing faster than a SEEK. By comparison, if you have 255 records, your worst case with a LOCATE is 255 comparisons. With a SEEK, your worst case is 8. This is because a SEEK begins at the mid-point of the table and determines whether or not the comparison yields a greater than, less than or equal to result. If it's not equal, it then moves to the left or right branch depending on whether it's greater than or less than. This repeats until a match is found. You're essentially dividing the table into two parts equal with each comparison that doesn't match.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform