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;

 

相关文章:

  • 2021-06-20
  • 2021-05-25
  • 2021-06-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2022-03-08
  • 2021-09-11
  • 2021-10-06
相关资源
相似解决方案