mysql执行计划

EXPLAINOutput Columns

 id (JSON name: select_id)

 

The SELECT identifier.This is the sequential number of the SELECT withinthe query. The value can be NULL if the row refers to the unionresult of other rows. In this case, the table column shows a valuelike <unionM,N> toindicate that the row refers to the union of the rows with id valuesof M and N.

包含一组数字,表示查询中执行select子句或操作表的顺序。id相同,执行顺序由上至下,如果是子查询,id的序号会递增,id值越大优先级越高,越先被执行,id如果相同,可以以认为是一组,从上往下顺序执行;在所有组中,id值越大,优先级越高,越先执行

id如果相同,可以认为是一组,从上往下顺序执行;在所有组中,id值越大,优先级越高,越先执行

 

 

select_type (JSONname: none)

 

 select_type (JSON name: none)

Thetype of SELECT, which can be any of those shownin the following table. A JSON-formatted EXPLAIN exposes the SELECT type as a property ofa query_block, unless it is SIMPLE or PRIMARY. The JSON names (whereapplicable) are also shown in the table.

table (JSON name: table_name

type

 

possible_keys 

 

The possible_keys columnindicates the indexes from which MySQL can choose to find the rows in thistable. 

key

 

 

 

The key column indicatesthe key (index) that MySQL actually decided to use.

要想强制MySQL使⽤用或忽视possible_keys列中

的索引,在查询中使⽤用FORCEINDEXUSEINDEX或者IGNORE

INDEX

key_len

 

 

 

The key_len columnindicates the length of the key that MySQL decided to use.

一般越短越好

ref

 

The ref column showswhich columns or constants are compared to the index named inthe key column to select rows from the table.

rows

 

 

 

The rows column indicatesthe number of rows MySQL believes it must examine to execute the query.

这只是一个预估值

filtered

 

 

 

The filtered columnindicates an estimated percentage of table rows that will be filtered by thetable condition. That is, rows shows

 the estimated number of rows examinedand rows × filtered / 100 shows the number ofrows that will be joined with previous tables.

extra

 

 

 

Distinct:一旦mysql找到了与行相联合匹配的行,就不再搜索了。

Notexists mysql优化了LEFTJOIN,一旦它找到了匹配LEFTJOIN标准的行,就不再搜索了。

Usingindex:说明查询是覆盖了索引的,这是好事情。MySQL直接从索引中过滤不需要的记录并返回命中的结果。这是

MySQL服务层完成的,无需再回表查询记录。

Usingwhere

使用了WHERE从句来限制哪些行将与下一张表匹配或者是返回给用户。

注意:Extra列出现Using where表⽰示MySQL服务器将存储引擎返回服务层以后再应用WHERE条件过滤。

Rangechecked for each Recordindexmap:#) :没有找到理想的索引,因此对从前面表中来的每一个行组合,

mysql检查使用哪个索引,并用它来从表中返回行。这是使用索引的最慢的连接之一。

UsingfilesortMySQL中无法利用索引完成的排序操作称为“文件排序”

看到这个的时候,查询就需要优化了。mysql需要进行额外的步骤来发现如何对返回的行排序。它根

据连接类型以及存储排序键值和匹配条件的全部行的行指针来排序全部行。

 

Usingtemporary :表示MySQL需要使用临时表来存储结果集,常见于排序和分组查询

Usingindex condition

这是MySQL 5.6出来的新特性,叫做“索引条件推送”。简单说⼀一点就是MySQL原来在索引上是不能执⾏行

like这样的操作的,但是现在可以了,这样减少了不必要的IO操作,但是只能⽤用在⼆二级索引上。

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值