advertise
« Lots of questions for high scalability / high availability | Main | Can you profit from the coming Content Delivery Network wars? »
Wednesday
Aug082007

Partial String Matching

Is there any alternative to LIKE '%...%' OR LIKE '%...%' in MySQL if you have to offer partial string matching on a large dataset?

Reader Comments (3)

MySQL allows you to do regular expressions using RLIKE. I don't know how the performance compares to using LIKE though. e.g.

SELECT * FROM my_table WHERE my_field LIKE '%foo%' or my_field LIKE '%bar%';

vs.

SELECT * FROM my_table WHERE my_field RLIKE '.*(foo|bar).*';

Here's the page in their doc:

http://dev.mysql.com/doc/refman/5.0/en/regexp.html

November 29, 1990 | Unregistered Commentermkemp

How would that possibly be faster? Also you might get queries like

field LIKE '%a%' AND (field LIKE '%b%' OR field LIKE '%c%')

November 29, 1990 | Unregistered CommenterAnonymous

I was looking for a product like Lucene but for partial string matching.

November 29, 1990 | Unregistered CommenterAnonymous

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>