I want to make a search for articles on my website - is it ok to use just plain 'LIKE' statement or is there a better search algorithm to use with MySQL? (its important it be efficient)
You should look into using Full-Text Search.
It might also help you to read about the Tradeoffs of MySQL LIKE vs Full-Text
is it ok to use just plain 'LIKE' statement or is there a better search algorithm to use with MySQL? (its important it be efficient)
Like
If it is important to be efficient then I think LIKE is absolutely not the way to go.
Full Text Search: 392 Sec Full Text Search (Cached): 272 Sec
Full Text Boolean Mode 12 Sec Full Text Boolean (Cached) 11 Sec
Mnogosearch (external) 3.5 Sec Mnogosearch (external cached) 1.06 Sec
Sphinx 0.23 Sec Sphinx Cached 0.15 Sec
LIKE %...% 30sec Sec LIKE %...% (Cached) 29sec Sec
Sphinx
Probably Sphinx is the most efficient method, which also has support for MySQL. To be honest I have never used Sphinx myself, but some very big sites use it.
It is probably more difficult to setup then another(probably last) alternative.
MySQL full-text search
I also think MySQL full-text-search would probably be fast enough and a easier to use.
I would consider Using Apache Solr https://lucene.apache.org/solr/ or Elastic Search http://www.elasticsearch.org/
© 2022 - 2024 — McMap. All rights reserved.