hoangvu68
hoangvu68

Reputation: 865

The performance of mysql fulltext depend on order of keyword

I am having problem with mysql fulltext search. When I change the order of keyword, the search speed changes. For example I have 4 queries, all of them return same result:

1) FAST (1s)

SELECT * FROM table WHERE (MATCH (column_data) AGAINST('+english* +php*' IN BOOLEAN MODE)

2) SLOW (10s)

SELECT * FROM table WHERE MATCH (column_data) AGAINST('+php* +english*' IN BOOLEAN MODE)

3) FAST (1s)

SELECT * FROM table WHERE MATCH (column_data) AGAINST('+php*' IN BOOLEAN MODE) AND (MATCH (column_data)) AGAINST('+english*' IN BOOLEAN MODE))

4) SLOW (10s)

SELECT * FROM table WHERE (MATCH (column_data) AGAINST('+english*' IN BOOLEAN MODE)) AND (MATCH (column_data) AGAINST('+php*' IN BOOLEAN MODE))

How can I optimize it?

Upvotes: 2

Views: 132

Answers (1)

hoangvu68
hoangvu68

Reputation: 865

I found a answer. That is because number of results of each keyword. We should put the keyword has small result on the top.

Upvotes: 0

Related Questions