Mysql 索引无效

索引无效

select * from teacher where id not in (1,3,4);
select * from teacher where teacherName like "%张"
select  * from teacher  where FROM_UNIXTIME(startTeacher) < CURDATE();
  1. 包含 not
  2. like 关键词中前缀 "%**"
  3. 在索引字段上进行 计算,对索引列进行运算,需要建立函数索引.
  4. 最左前缀
    单独引用复合索引非第一位置的索引列.
  5. 使用 join 时,两表的字段类型要相同
  6. is null 条件
    索引有序,null 无序,除非不用null,而用具体的数字
  7. or 左右必须是索引列
  8. end

改良建议

// 计算放到不相干字段(不是索引字段上)
select name from user where create_time < FROM_UNIXTIME(CURDATE());

建议可以考虑使用 Lucene 等全文索引工具来代替频繁的模糊查询。

猜你喜欢

转载自blog.csdn.net/ai_shuyingzhixia/article/details/82807972