Without more details it is hard how you can optimize a query.
1. even though database 1TB, what about the table on which your running
this query? Do you have any index on the column? How may chars long is the
2. Run the explain and see what is the optimizer is telling - using key or
not, full scan or not, etc.
3. see whether you can change the like to 'ABCpatron%'. See - "
http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html - The index also
can be used for
if the argument to
a constant string that does not start with a wildcard character."
4. you may want to take subset of data and try both RegEx and like. Compare
5. Also, see if you can make use of prefix-indexing where you only first N
characters are used.
On Sun, Dec 4, 2011 at 11:25 AM, Rafael Valenzuela <ravamo@stripped> wrote:
> Hi all,
> 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?
> thanks a lot
> Mit forever
> My Blog <http://www.redcloverbi.wordpress.com>
> My Faborite Web<