zoukankan      html  css  js  c++  java
  • 8.8.2 EXPLAIN Output Format

    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 结果,在这种情况下, 表列显示一个值像

  • 相关阅读:
    文件格式——gff格式
    文件格式——fastq格式
    Java 8 新特性:1-函数式接口
    10分钟学会JAVA注解(annotation)
    spring MVC 乱码问题
    Tomcat 连接池详解
    DBCP连接池配置参数说明
    spring 事务无效解决方法
    spring mvc 存取值
    使用Criteria 实现两表的左外连接,返回根对象
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351411.html
Copyright © 2011-2022 走看看