Is there any alternative to LIKE '%...%' OR LIKE '%...%' in MySQL if you have to offer partial string matching on a large dataset?
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
How would that possibly be faster? Also you might get queries like
field LIKE '%a%' AND (field LIKE '%b%' OR field LIKE '%c%')
I was looking for a product like Lucene but for partial string matching.
More information about formatting options
re: Partial String Matching
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
How would that possibly be
How would that possibly be faster? Also you might get queries like
field LIKE '%a%' AND (field LIKE '%b%' OR field LIKE '%c%')
I was looking for a product
I was looking for a product like Lucene but for partial string matching.
Post new comment