mysql like performance boost

user121196 picture user121196 · Mar 20, 2010 · Viewed 21.8k times · Source

is there anyway to speed up mysql like operator performance if wild card is involved? eg. like '%test%'

Answer

Cal picture Cal · Mar 20, 2010

MySQL can use an index if your query looks like foo LIKE 'abc%' or foo LIKE 'abc%def%'. It can use the index for any portion or the string before the first wildcard. If you need to match a word anywhere within a string, you might want to consider using FULLTEXT indexes instead.

More detail on indexes: http://dev.mysql.com/doc/refman/5.1/en/mysql-indexes.html

Full text search: http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html