Presto 0.100 Documentation

7.7. 解释

7.7. 解释

概述

EXPLAIN [ ( option [, ...] ) ] statement

option可以为以下之一:

    FORMAT { TEXT | GRAPHVIZ }
    TYPE { LOGICAL | DISTRIBUTED }

说明

显示一个语句的逻辑或分布式执行方案。

示例

逻辑方案:

presto:tiny> EXPLAIN SELECT regionkey, count(*) FROM nation GROUP BY 1;
                                             Query Plan
----------------------------------------------------------------------------------------------------------
- Output[regionkey, _col1] => [regionkey:bigint, count:bigint]
         _col1 := count
    - Exchange[GATHER] => regionkey:bigint, count:bigint
         - Aggregate(FINAL)[regionkey] => [regionkey:bigint, count:bigint]
                 count := "count"("count_8")
            - Exchange[REPARTITION] => regionkey:bigint, count_8:bigint
                 - Aggregate(PARTIAL)[regionkey] => [regionkey:bigint, count_8:bigint]
                         count_8 := "count"(*)
                    - TableScan[tpch:tpch:nation:sf0.01, original constraint=true] => [regionkey:bigint]
                             regionkey := tpch:tpch:regionkey:2

分布式方案:

presto:tiny> EXPLAIN (TYPE DISTRIBUTED) SELECT regionkey, count(*) FROM nation GROUP BY 1;
                                             Query Plan
----------------------------------------------------------------------------------------------
Fragment 2 [SINGLE]
     Output layout: [regionkey, count]
    - Output[regionkey, _col1] => [regionkey:bigint, count:bigint]
             _col1 := count
        - RemoteSource[1] => [regionkey:bigint, count:bigint]

Fragment 1 [FIXED]
     Output layout: [regionkey, count]
    - Aggregate(FINAL)[regionkey] => [regionkey:bigint, count:bigint]
             count := "count"("count_8")
        - RemoteSource[0] => [regionkey:bigint, count_8:bigint]

Fragment 0 [SOURCE]
    Output layout: [regionkey, count_8]
    Output partitioning: [regionkey]
    - Aggregate(PARTIAL)[regionkey] => [regionkey:bigint, count_8:bigint]
             count_8 := "count"(*)
        - TableScan[tpch:tpch:nation:sf0.01, original constraint=true] => [regionkey:bigint]
                 regionkey := tpch:tpch:regionkey:2