对于SELECT语句,该
        EXPLAIN语句会产生额外的(“扩展”)信息,这些信息不是
        EXPLAIN输出的一部分,但可以通过发出SHOW WARNINGS
        后面的语句来查看EXPLAIN。输出中的
        Message值SHOW
        WARNINGS显示优化器如何限定
        SELECT语句
        中的表名和列名,SELECT应用重写和优化规则后的样子,以及可能的关于优化过程的其他注释。
      
SHOW WARNINGS可在语句后
        
        显示的扩展信息
        EXPLAIN仅针对
        SELECT语句生成。
        SHOW WARNINGS显示其他可解释语句(DELETE、
         INSERT、
        REPLACE和
        UPDATE)的空结果。
          在较旧的 MySQL 版本中,扩展信息是使用EXPLAIN
          EXTENDED. 该语法仍然被识别为向后兼容,但扩展输出现在默认启用,因此该EXTENDED关键字是多余的且已弃用。它的使用会导致警告;EXPLAIN希望在未来的 MySQL 版本中将其
从
          语法中删除。
        以下是扩展
        EXPLAIN输出的示例:
      
mysql> EXPLAIN
       SELECT t1.a, t1.a IN (SELECT t2.a FROM t2) FROM t1\G
*************************** 1. row ***************************
           id: 1
  select_type: PRIMARY
        table: t1
         type: index
possible_keys: NULL
          key: PRIMARY
      key_len: 4
          ref: NULL
         rows: 4
     filtered: 100.00
        Extra: Using index
*************************** 2. row ***************************
           id: 2
  select_type: SUBQUERY
        table: t2
         type: index
possible_keys: a
          key: a
      key_len: 5
          ref: NULL
         rows: 3
     filtered: 100.00
        Extra: Using index
2 rows in set, 1 warning (0.00 sec)
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
  Level: Note
   Code: 1003
Message: /* select#1 */ select `test`.`t1`.`a` AS `a`,
         <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in
         ( <materialize> (/* select#2 */ select `test`.`t2`.`a`
         from `test`.`t2` where 1 having 1 ),
         <primary_index_lookup>(`test`.`t1`.`a` in
         <temporary table> on <auto_key>
         where ((`test`.`t1`.`a` = `materialized-subquery`.`a`))))) AS `t1.a
         IN (SELECT t2.a FROM t2)` from `test`.`t1`
1 row in set (0.00 sec)
        因为显示的语句SHOW
        WARNINGS可能包含特殊标记以提供有关查询重写或优化器操作的信息,所以该语句不一定是有效的 SQL 并且不打算执行。输出还可能包括具有值的行,这些
        Message值提供有关优化器采取的操作的额外非 SQL 解释性说明。
      
        以下列表描述了可以出现在由 显示的扩展输出中的特殊标记SHOW
        WARNINGS:
- <auto_key>- 为临时表自动生成的键。 
- <cache>(- expr)- 表达式(例如标量子查询)执行一次,结果值保存在内存中供以后使用。对于包含多个值的结果,可能会创建一个临时表,您可能会看到 - <temporary table>。
- <exists>(- query fragment)- 子查询谓词转换为 - EXISTS谓词,子查询转换为可以与- EXISTS谓词一起使用。
- <in_optimizer>(- query fragment)- 这是一个没有用户意义的内部优化器对象。 
- <index_lookup>(- query fragment)- 使用索引查找来处理查询片段以查找符合条件的行。 
- <if>(- condition,- expr1,- expr2)- 如果条件为真,则求值为 - expr1,否则 为- expr2。
- <is_not_null_test>(- expr)- 验证表达式不计算为 的测试 - NULL。
- <materialize>(- query fragment)- 使用子查询实现。 
- `materialized-subquery`.- col_name- col_name对内部临时表中 列的引用具体 化以保存评估子查询的结果。
- <primary_index_lookup>(- query fragment)- 使用主键查找来处理查询片段以查找符合条件的行。 
- <ref_null_helper>(- expr)- 这是一个没有用户意义的内部优化器对象。 
- /* select#- N*/- select_stmt- The - SELECTis associated with the row in non-extended- EXPLAINoutput that has an- idvalue of- N.
- outer_tablessemi join (- inner_tables)- A semijoin operation. - inner_tablesshows the tables that were not pulled out. See Section 8.2.2.1, “Optimizing Subqueries, Derived Tables, and View References with Semijoin Transformations”.
- <temporary table>- This represents an internal temporary table created to cache an intermediate result. 
        当某些表属于const
        或system类型时,涉及这些表中的列的表达式会由优化器及早评估,而不是显示语句的一部分。但是,对于FORMAT=JSON,某些
        const表访问显示为ref使用 const 值的访问。