当前位置:Gxlcms > 数据库问题 > Mysql索引优化2

Mysql索引优化2

时间:2021-07-01 10:21:17 帮助过:21人阅读

  • simple (不含子查询)
  • primary(含有子查询或派生查询)
    • subquery (非from子查询)
    • derived (from型子查询)
    • union
    • union result
  • type字段 分析查询的关键字段
    • all < index < range < ref < eq_ref < (const, system, null)
    • all 全表扫描
    • index 扫描索引树上全部的索引节点
    • range 根据索引做范围的扫描
    • ref 通过索引列,直接引用到某些数据行
    • eq_ref 通过索引列,直接引用一行数据,常用于连接中
    • 一般按照主键查询时,易出现const, system 当查询不经过表时会出现null
  • table字段
    • 真实的表名
    • 临时表 如as tmp
    • derived 如from型子查询
    • null 不使用表
  • ref字段
    • 连接查询时,表之间字段的引用关系
  • possible key字段
    • 可能使用的索引
  • key 字段
    • 最终使用的索引
  • key len 字段
    • 实际使用索引的长度
  • rows 字段
    • 估计要扫描多少行
  • extra 字段
    • using index 用到了索引覆盖
    • using where 光靠索引定位不了,还得where判断一下
    • using temporary 用到了临时表,效果已经非常不好了
    • using filesort 文件排序,可能在磁盘,也可能在内存中
  • Mysql索引优化2

    标签:extra   解释   post   sele   文件   plain   div   就是   查询   

    人气教程排行