您的位置:首页 > 大数据 > 人工智能

8.8.2 EXPLAIN Output Format

2015-08-28 15:22 363 查看
8.8.2 EXPLAIN Output Format

EXPLAIN 语句提供信息关于SELECT 语句的执行计划:

EXPLAIN 返回SELECT 语句使用的每个表的行信息, 它列出了MySQL 会读取它们当处理语句时候的输出的顺序。

MySQL 解决所有的连接使用嵌套循环方法,这意味着MySQL 从第一个表读取一条记录,

在第2个表,第三个表,等等中找到匹配的行,

当所有的表被处理后,MySQL 输出选择的列。

当使用EXTENDED 关键字被使用,EXPLAIN 产生额外的信息,可以通过执行

SHOW WARNINGS 语句在EXPLAIN语句后面,EXPLAIN EXTENDED 也显示过滤的列。

注意:

你不能是用EXTENDED 和PARTITIONS 关键字一起使用在同样的EXPLAIN 语句里,

EXPLAIN Output Columns EXPLAIN 输出格式

EXPLAIN Join Types EXPLAIN Join 类型

EXPLAIN Extra Information EXPALIN 额外的信息

EXPLAIN Output Interpretation EXPLAIN 输出解释

解释输出列:

本节介绍了解释EXPLAIN 产生的输出列,稍后部分提供关于该类型和额外列的附加信息。

EXPLAIN 每个输出行提供了关于一个表的信息, 每个行包含8.1中总结的值,

EXPLAIN 的输出列,并在表中更详细地描述。列名在表的第一列显示;第二列提供了等效的属性名称,在输出时显示格式为JSON的使用

Column JSON Name Meaning

id select_id The SELECT identifier

select_type None The SELECT type

table table_name The table for the output row

partitions partitions The matching partitions

type access_type The join type

possible_keys possible_keys The possible indexes to choose

key key The index actually chosen

key_len key_length The length of the chosen key

ref ref The columns compared to the index

rows rows Estimate of rows to be examined

filtered filtered Percentage of rows filtered by table condition

Extra None Additional information

mysql> explain SELECT cpi.personName, ccd.clientSn, ccd.income, ccd.pay, ccd.accountBalance, ccd.createdTime, ccd.remark from

-> (select * from ClientCashDetail ccd_int where

-> 1 >

-> (SELECT count(clientSn) from ClientCashDetail

-> where clientSn= ccd_int.clientSn and ccd_int.createdTime < createdTime and createdTime < TIMESTAMP(@dated_time) )

-> and ccd_int.createdTime < TIMESTAMP(@dated_time)

-> ) ccd

-> RIGHT JOIN ClientPersonalInfo cpi on cpi.clientSn = ccd.clientSn

-> where ccd.clientSn in (SELECT clientSn from ClientPersonalInfo where personName in (

-> ‘蔡明’,

-> ‘苑秀凤’,

-> ))
-> ORDER BY cpi.personName,  ccd.clientSn,  ccd.createdTime DESC;


+—-+——————–+——————–+——–+—————+————-+———+——————-+——+———————————+

| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |

+—-+——————–+——————–+——–+—————+————-+———+——————-+——+———————————+

| 1 | PRIMARY | cpi | ALL | PRIMARY | NULL | NULL | NULL | 937 | Using temporary; Using filesort |

| 1 | PRIMARY | ClientPersonalInfo | eq_ref | PRIMARY | PRIMARY | 4 | zjzc.cpi.clientSn | 1 | Using where |

| 1 | PRIMARY | | ref | | | 4 | zjzc.cpi.clientSn | 10 | NULL |

| 2 | DERIVED | ccd_int | ALL | NULL | NULL | NULL | NULL | 5999 | Using where |

| 3 | DEPENDENT SUBQUERY | ClientCashDetail | ALL | NULL | NULL | NULL | NULL | 5999 | Using where |

+—-+——————–+——————–+——–+—————+————-+———+——————-+——+———————————+

5 rows in set (0.11 sec)

注意:

JSON 的属性是空的不显示的在JSON 格式里

id (JSON name: select_id) 第一列select ID

SELECT 标示符,这是查询中SELECT 特定的顺序的号码。 该值可以为NULL,

如果行指向其它行的的union 结果,在这种情况下, 表列显示一个值像
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: