Hive的Explain命令

Hive的Explain命令,用于显示SQL查询的执行计划。

Hive查询被转化成序列阶段(这是一个有向无环图)。这些阶段可能是mapper/reducer阶段,或者是Metastore或文件系统的操作,如移动和重命名的阶段。

例子 

hive> explain [extended] --加上关键字extended,则显示抽象语法树
    > select * from student                
    > cluster by age;

 1.查询的抽象语法树(没用,可以忽略)

2.执行计划计划的不同阶段之间的依赖关系(很重要)

OK
STAGE DEPENDENCIES:
  Stage-1 is a root stage
  Stage-0 is a root stage

3.每个场景的描述

STAGE PLANS:
  Stage: Stage-1
    Map Reduce
      Map Operator Tree:        //发生在job的 map 处理阶段过程
          TableScan        //读取表的数据
            alias: student      //表名为student,若select * from emp e;表有别名则显示别名e
            Statistics: Num rows: 0 Data size: 74 Basic stats: PARTIAL Column stats: NONE
            Select Operator
              expressions: age (type: int), name (type: string)
              outputColumnNames: _col0, _col1
              Statistics: Num rows: 0 Data size: 74 Basic stats: PARTIAL Column stats: NONE
              Reduce Output Operator
                key expressions: _col0 (type: int)
                sort order: +
                Map-reduce partition columns: _col0 (type: int)
                Statistics: Num rows: 0 Data size: 74 Basic stats: PARTIAL Column stats: NONE
                value expressions: _col0 (type: int), _col1 (type: string)
      Reduce Operator Tree:      //发生在job的 reduce 处理阶段过程
        Extract
          Statistics: Num rows: 0 Data size: 74 Basic stats: PARTIAL Column stats: NONE
          File Output Operator
            compressed: false
            Statistics: Num rows: 0 Data size: 74 Basic stats: PARTIAL Column stats: NONE
            table:
                                //说明输入格式是TextInputFormat
                input format: org.apache.hadoop.mapred.TextInputFormat
                                //说明输出格式是HiveIgnoreKeyTextOutputFormat
                output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
                serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe

  Stage: Stage-0
    Fetch Operator
      limit: -1                    //--job中没有Limit 

Time taken: 0.085 seconds, Fetched: 36 row(s)

 

posted @ 2015-08-17 18:52  skyl夜  阅读(8376)  评论(0编辑  收藏  举报