I have a little problem with the performance of a mysql-query which uses a fulltext index.
The following query
SELECT Mention.id
FROM mentions AS Mention
WHERE (MATCH (`Mention`.`title_text`, `Mention`.`content_text`, `Mention`.`author_text`)
AGAINST ('"hannover 96"' IN BOOLEAN MODE))
takes about 3 seconds.
If I change the fulltext-condition to
SELECT Mention.id
FROM mentions AS Mention
WHERE (MATCH (`Mention`.`title_text`, `Mention`.`content_text`, `Mention`.`author_text`)
AGAINST ('+hannover +96' IN BOOLEAN MODE))
the query takes just about 0.001 seconds.
So is there a possibility to get a better performance of the first query? It’s important to search for the complete string “hannover 96” and not for records which contain hannover and 96.
Thanks for some tips!
Best regards,
Timo
Best Answer
The
WHERE
clauses of your queries are asking for completely different thingshannover 96
within the three columns mentioned inMATCH
clause.hannover
and96
within the three columns mentioned inMATCH
clause.Fulltext indexes index tokens very well. Consequently, exact strings that contains multiple tokens should take longer to process.
The only way to find
hannover 96
faster is to use a subquery.or
Give it a Try !!!