如标题所示,您如何知道查询是否使用FTS索引?MySQL - 如何知道查询是否使用FTS索引
通常它显示using index condition
。
我的查询语句:
SELECT *
FROM news
WHERE MATCH(news_title,news_keywords) AGAINST ('news')
AND news_date_created BETWEEN '2016-01-01' AND '2016-12-31'
和执行EXPLAIN
,给了我:
+----+-------------+-------+------------+----------+--------------------------+------------+---------+-------+------+----------+-------------------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+----------+--------------------------+------------+---------+-------+------+----------+-------------------------------+
| 1 | SIMPLE | news | NULL | fulltext | news_date_idx,news_title | news_title | 0 | const | 1 | 100.00 | Using where; Ft_hints: sorted |
+----+-------------+-------+------------+----------+--------------------------+------------+---------+-------+------+----------+-------------------------------+
如果它使用索引或没有我不知道。它只是说它使用where and ft_hints
。
据我所知,如果您使用'MATCH ... AGAINST'并且没有合适的索引,它只会引发错误。与常规查询不同,这不是可以在没有索引的情况下获得的数据。 –
@ÁlvaroGonzález不,这不完全正确。 – Shadow
@Shadow我会很欣赏这方面的一个例子。 MySQL可以搜索“公共房屋”并找到带有FT索引的“普通房屋”吗? –