zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

MySQL explain使用以及EXTRA类型解读

2023-04-18 13:13:31 时间

使用explain查看SQL语句执行分析

-- 查询某表的name、score字段
--我们使用SQLname,score from person where score = '90';
select 
explain select column from table;
explain select name,score from person where score = '90';
  • id: SELECT 查询的标识符. 每个 SELECT 都会自动分配一个唯一的标识符.
  • select_type: SELECT 查询的类型.
  • table: 查询的是哪个表
  • partitions: 匹配的分区
  • type: join 类型
  • possible_keys: 此次查询中可能选用的索引
  • key: 此次查询中确切使用到的索引.
  • ref: 哪个字段或常数与 key 一起被使用
  • rows: 显示此查询一共扫描了多少行. 这个是一个估计值.
  • filtered: 表示此查询条件所过滤的数据的百分比
  • extra: 额外的信息