Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Speeding up search - Locate For or Seek?
Message
 
À
26/07/2000 10:50:58
Erin Eby
Mission Critical Software
Gainesville, Floride, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00397065
Message ID:
00397074
Vues:
20
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform