SQL优化

31 阅读1分钟

explain执行计划

id:查询表的顺序 id相同从上到下 id不同从大到小

type:访问的类型 null,system,const,eq_ref,ref,range,index,all

null: select A

system: 访问系统表

const: 通过索引一次找到

eq_ref:主键或唯一索引扫描

ref: 非唯一索引扫描

all: 全表扫描

index: 用了索引但是会扫描索引树(全索引扫描)