什么';s是为下面的查询创建索引的最佳方式


What's is the best way to create indexes for the query below

我有这个查询:

select * from `metro_stations`
where `is_active` = 1
  and (`title` like '%search%' or `title_en` like '%search%')

如果is_active是TINYINT字段,标题是VARCHAR(255),如何创建有效索引?

这个查询呢:

select * from `metro_stations`
where `is_active` = 1
 and (`title` like '%search%' or
      `title_en` like '%search%' or
      `description` like '%search%')

如果描述字段是文本?

对每列使用全文索引。如果在查询中使用"或"单独使用fts索引,如果使用"answers"混合fts索引(在一个索引中使用多列)全文索引

FULLTEXT(title, title_en)
WHERE is_active = 1
  AND MATCH(title, title_en) AGAINST ("+search" IN BOOLEAN MODE)

(这应该适用于InnoDB(5.6+)或MyISAM。)

请记住FULLTEXT中"单词长度"answers"停止单词"的限制。