MySQL模糊查询效率

1. like '%keyword%' 的方式不会走索引,全表扫描

select *from table where column like '%keyword%';

2. regexp 都不会走索引

3. like 'keyword%' 的方式会走索引,但要求查询的关键词都在开头

select *from table where column like 'keyword%';

column字段有索引,配合使用

4. LOCATE & POSITION &INSTR 会比 like '%%'块

select *from table where LOCATE('keyword', column)>0;

select *from table where POSITION('keyword' IN column);

select *from table where INSTR(column,'keyword' )>0;

原文地址:https://www.cnblogs.com/skyEva/p/13409575.html