>I have a very large table over 300,000 records
>
>I am using locate for command
>I can not use seek because I have conditions seek does not fulfill
>
>The first time a use the command locate,it is very slow
>
>The second time and then, locate is very fast
>
>The command is in a button of a form and table in date environment
>If I close the form, the first time I use locate it is slow again
>
>Is there any explanation for it ?
300K is not very large IMHO. I don't really have an explanation w/o knowing the indexes and the criteria you use, deleted etc (and explanation wouldn't help you much anyway).
Instead, you say that you can't use seek because it doesn't fulfill your conditions, but does current order at least fulfill part of your conditions? If it does then you can combine a seek with a locate which would be very fast. i.e:
USE (_samples+'data\orders') order tag cust_id
lcId = 'ERNSH'
seek m.lcid
locate for order_amt < 500 WHILE cust_id = m.lcid
This 'locate' Unlike:
LOCATE FOR cust_id = m.lcid and order_amt < 500
benefits from the index and does the subsequent movement in a portion of the table (where ordered records' cust_id is 'ERNSH').
Locate is said to be rushmore optimizable but I doubt and there are reasons that would beat the optimization anyway. Using seek+locate you would have at least have a controlled optimization.
Cetin