Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is faster, locate or seek ?
Message
From
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:
00344194
Views:
22
>>
In any case you would obtain an expression that locate could benefit the index.
>
>Cetin, can you explain the above comment, I don't understand, sorry.
>
>Mark


Mark,
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)

and it would benefit indexes. For these type of locates there is no simple seek replacement. Now if you wanted to search for a full PK and one the single tags is missing then you would build an expression to benefit rushmore :
lcSearchExpr = padl(1,5,"0")+ ;
dtos({^2000/1/1})+;
padl(5,5,"0")+;
"1"+myChar

or a partail one :
lcSearchExpr = padl(1,5,"0")+ dtos({^2000/1/1})

both would use the myMain tag. It would also be affected by "set deleted" and if you have indexes on deleted() and/or myMain is filtered (filtering PK is arguable - and I don't say you must or mustn't). In any case a locate optimization should check the indexes it can use and it consumes time theoritically. For seek, since you're comparing both in speed I suppose you accept that you already have a suitable tag to use (here myMain for full or sample partial PK) :
seek(lcSearch, "myTable", "myMain")
would directly select and use that tag. It also has an advantage that you don't need to change workarea or current tag :)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform