开发者

MySQL fulltext searching: fulltext and INT columns in the same query

开发者 https://www.devze.com 2023-01-24 04:32 出处:网络
I have a fulltext index on column \"SEARCH\". But the query contains additional \"AND\" condition where tinyint column \"VEGETARIAN\" is involved.

I have a fulltext index on column "SEARCH". But the query contains additional "AND" condition where tinyint column "VEGETARIAN" is involved.

What is the best solution for this situation? To leave as it is - fulltext index just on "SEARCH" column? To create one more index on "VEGETARIAN" column?

$result = mysql_query( "SELECT title FROM recipes where 
match(search) against('$query' in boolean mode) and vegetarian='1' 
开发者_StackOverflow中文版limit $start, $step");     

Thanks.


The extra index on vegetarian would make things faster if less than 50% of the rows have vegetarian = 1


I doubt indexing vegetarian will have any effect as the text search will have to be run first and then the non vegetarian rows filtered out. Best way with this kind of thing is try it and see if it works.

0

精彩评论

暂无评论...
验证码 换一张
取 消