当与条件字数一起使用时,全文索引在布尔模式下被忽略
当我为其布尔模式添加一些有条件的单词时,全文匹配会忽略其索引。选择如下:
explain select * from seeds WHERE MATCH(text) AGAINST ("mount cameroon" IN BOOLEAN MODE);
输出
+----+-------------+-------+----------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+----------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | seeds | fulltext | text | text | 0 | | 1 | Using where |
+----+-------------+-------+----------+---------------+------+---------+------+------+-------------+
具有多个单词条件
explain select * from seeds WHERE MATCH(text) AGAINST ("mount cameroon" IN BOOLEAN MODE) = 4;
输出
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | seeds | ALL | NULL | NULL | NULL | NULL | 9607 | Using where |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
的相同查询,这肯定不是正确的行为吗?
fulltext match is ignoring its index when I add a number of words conditional for its boolean mode. The selects are as follows:
explain select * from seeds WHERE MATCH(text) AGAINST ("mount cameroon" IN BOOLEAN MODE);
outputs
+----+-------------+-------+----------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+----------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | seeds | fulltext | text | text | 0 | | 1 | Using where |
+----+-------------+-------+----------+---------------+------+---------+------+------+-------------+
the same query with a number of words conditional
explain select * from seeds WHERE MATCH(text) AGAINST ("mount cameroon" IN BOOLEAN MODE) = 4;
outputs
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | seeds | ALL | NULL | NULL | NULL | NULL | 9607 | Using where |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
surely this cant be correct behaviour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
诊断结果是,当全文匹配中添加任何条件时,Mysql优化器很容易混淆。解决方案是重构查询(拆分为子查询和联接)。
此诊断和解决方案由 RolandoMySQLDBA (https://stackoverflow.com/users/491757/rolandomysqldba) 提供,并且此处提供完整内容
优化mysql全文搜索,
这里
https://dba.stackexchange.com/ questions/7136/fulltext-index-ignored-in-boolean-mode-with-number-of-words-conditional。
The diagnosis is that the Mysql optimizer is readily confused when any condition is added to a fulltext MATCH. Solution is to refactor the query (split into subqueries and join).
This diagnosis and solution is kindly provided by RolandoMySQLDBA (https://stackoverflow.com/users/491757/rolandomysqldba), and availablein full here
Optimizing mysql fulltext search,
and here
https://dba.stackexchange.com/questions/7136/fulltext-index-ignored-in-boolean-mode-with-number-of-words-conditional.