如標題所示,您如何知道查詢是否使用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索引的「普通房屋」嗎? –