Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best efficient way to make a fulltext search in MySQL

I have 3 tables, and I want to make a query for a search term textbox. My query currently looks something like this:

SELECT Artist.* FROM Artist, Band, Instrument WHERE MATCH (Artist.name) AGAINST ('mysearchterm') OR MATCH (Band.name) AGAINST ('mysearchterm') OR MATCH (Instrument.name, Instrument.description) AGAINST ('mysearchterm');

This query is taking too much time to get executed. Is there any way to improve this? Am I doing something wrong?

Thanks

like image 841
John 5 Avatar asked Dec 29 '22 16:12

John 5


2 Answers

I would move to a fulltext search engine instead of trying to optimize this.

http://www.sphinxsearch.com/about.html

like image 165
Mark L Avatar answered Jan 02 '23 10:01

Mark L


MYSQL has full text search support that will give much better performance.

http://dev.mysql.com/doc/refman/5.0/en/fulltext-restrictions.html

However, I would recommend using a system designed for fulltext search if you intend to place any significant load on your application.

like image 44
Cullen Walsh Avatar answered Jan 02 '23 11:01

Cullen Walsh