>I have a table with 98,000 records, i need to implement searchs to this table, i'm using a sentence like this:
>
>Select * from Databasename!Tablename where tablename.fieldname like "%nametosearch%" into cursor Query
>
>the first time that i run the query it takes 173 sec
>the second time i run the query it takes 105 sec
>the third time i run the query it takes 47 sec
>after the third query run the answer search time is less than 2 sec.
>
>my customer search in this table for names, but he does eventually, and only search one name.
>
>Please sugestions for speed the first's runs of the query string.
>
>I have tried SET OPTIMIZE ON and OFF but the time for the first runs is very slow 160 sec.
>
>Exist any whay to optimize a query results for the first run.
>
>My table contains only names.
>
>
>Thanks and Regards
Guillermo, the right way to speed up quieries is to have the right indexes. If you have the indexes on the table matching your query expressions you should be able to get the result in fractions of second. Quieries with no indexes (or not all required indexes) may speed up after several runs due to the fact that by that time a good portion of DBF and indexes are already in RAM.
In your case you cannot get the exact index matching the "%nametosearch%" expression, so you cannot speed it up significantly.
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro
"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison