【发布时间】:2016-02-23 02:26:49
【问题描述】:
我有这个问题:
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%')
如果描述字段是文本?
【问题讨论】:
-
'%search%不是 SARGable。想想全文索引 -
仅供参考en.wikipedia.org/wiki/Sargable。
LIKE是 SARGable 但只有%在末尾search%在这里查看一些示例 stackoverflow.com/questions/799584/…