查詢創建索引的最佳方法我有這個疑問:什麼是下面
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。想想全文索引 – lad2025
供參考https://en.wikipedia.org/wiki/Sargable。 'LIKE'是SARGable,但只有'%'在末尾'search%''看到這裏的一些示例http://stackoverflow.com/questions/799584/what-makes-a-sql-statement-sargable –