列を持つ「articles」テーブルがあるとしましょう。
article_text: fulltext indexed
author_id: indexed
今、私は特定のアーサーが書いた記事に現れる用語を検索したいと思います。
だから次のようなもの:
select * from articles
where author_id=54
and match (article_text) against ('foo');
このクエリのexplainは、mysqlがフルテキストインデックスのみを使用することを示しています。mysqlは1つのインデックスしか使用できないと思いますが、特定の著者が最初に書いたすべての記事を取得してから、用語を全文検索するのは賢明な考えのようです... mysqlを支援する方法はありますか?
たとえば..あなたが自己参加した場合は?
select articles.* from articles as acopy
join articles on acopy.author_id = articles.author_id
where
articles.author_id = 54
and match(article_text) against ('foo');
この説明では、最初にauthor_idインデックスを使用し、次に全文検索を使用する方法を示しています。
これは、author_idでフィルタリングされた限定セットに対して、実際には全文検索のみを実行していることを意味しますか?
補遺
自己参加の計画を次のように説明します。
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: acopy
type: ref
possible_keys: index_articles_on_author_id
key: index_articles_on_author_id
key_len: 5
ref: const
rows: 20
filtered: 100.00
Extra: Using where; Using index
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: articles
type: fulltext
possible_keys: index_articles_on_author_id,fulltext_articles
key: fulltext_articles
key_len: 0
ref:
rows: 1
filtered: 100.00
Extra: Using where
2 rows in set (0.00 sec)