Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is faster, locate or seek ?
Message
 
To
10/03/2000 10:21:44
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00344153
Message ID:
00344216
Views:
33
>Suppose you have fields like :
>
>myId i
>myDate d
>myCheckNumber i
>myStatus l
>myChar c(10)
>
>and index tags with keys :
>
>myId - myId
>myDate - myDate
>myCheckNumber - myCheckNumber
>myStatus - myStatus
>myChar - myChar
>myMain - padl(myId,5,"0")+ ;
>dtos(myMain)+;
>padl(myCheckNumber,5,"0")+;
>iif(myStatus,"1","0")+;
>myChar
>
>In this case you could say :
>locate for myId = 3 and myCheckNumber = 5 and between(myDate, dDate1, dDate2)

Sometimes, and different situations call for different approaches, it makes sense to do a combination of seek and locate. For instance, this one seek might not be as fast as:

if seek(3, "TableAlias", "myId")
locate for myCheckNumber = 5 and between(myDate, dDate1, dDate2) while myId = 3
endif

If the table will have more than a small number of records, this will almost definitely be faster.

You would probably also want to seek on the most unique key of the conditions. In other words, if there are most likely hundreds of records with myId equaling 3 and only a few records with myCheckNumber equaling 5, you would want to do this instead:

if seek(5, "TableAlias", "myCheckNumber ")
locate for myId = 3 and between(myDate, dDate1, dDate2) while myCheckNumber = 5
endif

BTW Cetin, this is being copied to Mark. I only replied to you so I could work with your example.

Take care,
Joe
Joseph C. Kempel
Systems Analyst/Programmer
JNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform