Hello Everyone!..
A while back, I posted a question as to what is better Seek or Locate. Many users posted repsones and some of them had mentioned that Locate (with indexed table) could be as effective as the Seek Command.
So I tested it.
I created one Table, and ONLY 1 Field (Char 10) Indexed Ascending.
and then I created a small prg to insert 5 milion records.
nCount = 1
do while nCount <=5000000
Y = ltrim(str(nCount))
Append Blank
Replace Field1 with Y
Enddo
And then, I create a small form, with a Grid, and 2 text boxes. On each one of them in the Lost focus, I used Either
Seek and one I used a Locate, and I timed it.
x = seconds()
Set order to Field1
Seek this.value
if !eof()
Messagebox('found and it took: ' + str(seconds()-x,5,5))
else
messagebox('Sorry, not found')
endif
Same thing with the locate.
And the seek always took .0016 or so seconds,
And the locate took from 1 second to 7 seconds....
Is that normal?
I know that seek will ONLY work on 1 index at a time. And locate can optimise the query on multiple index.... But, I haven't tried it.... How fast can a locate be on such table or that size?
Let me know what you think.
Thank you in advance! Tekno
A while back, I posted a question as to what is better Seek or Locate. Many users posted repsones and some of them had mentioned that Locate (with indexed table) could be as effective as the Seek Command.
So I tested it.
I created one Table, and ONLY 1 Field (Char 10) Indexed Ascending.
and then I created a small prg to insert 5 milion records.
nCount = 1
do while nCount <=5000000
Y = ltrim(str(nCount))
Append Blank
Replace Field1 with Y
Enddo
And then, I create a small form, with a Grid, and 2 text boxes. On each one of them in the Lost focus, I used Either
Seek and one I used a Locate, and I timed it.
x = seconds()
Set order to Field1
Seek this.value
if !eof()
Messagebox('found and it took: ' + str(seconds()-x,5,5))
else
messagebox('Sorry, not found')
endif
Same thing with the locate.
And the seek always took .0016 or so seconds,
And the locate took from 1 second to 7 seconds....
Is that normal?
I know that seek will ONLY work on 1 index at a time. And locate can optimise the query on multiple index.... But, I haven't tried it.... How fast can a locate be on such table or that size?
Let me know what you think.
Thank you in advance! Tekno