;>>> 2011/12/04 20:25 +0100, Rafael Valenzuela >>>>
In one query, I am comparing a string with a 'like=%patron%', but is very
slow and expensive .What is the best way to compare a string? like or
regular expression?
The data base is too big table 1TB, any idea?
<<<<<<<<
Any decent implementation of "like '%patron%'" is in the gross linear, and
also, say, LOCATE('patron', ) in a setting where only 0 or not 0 is tested for.
If all your LIKE-searches look like this one, a string to be matched from a
value by putting it between '%'s, maybe by using "LOCATE" you can save
time--unless the MySQL developers were clever enough to make a special case of
this, and used the same algorithm for both. (One can always use the Boyer-Moore
algorithm for "LOCATE".)
In any case, if an in-the-gross-linear algorithm is used and that is too slow,
indexing is the only help, and, as Shiva said, you have to know your problem.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql