执行信息
以如下SQL语句在pretty模式下的执行结果为例:
gaussdb=# select sum(t2.c1) from t1,t2 where t1.c1=t2.c2 group by t1.c2;
执行EXPLAIN PERFORMANCE输出为:
gaussdb=# explain performance select sum(t2.c1) from t1,t2 where t1.c1=t2.c2 group by t1.c2;
id | operation | A-time | A-rows | E-rows | E-distinct | Peak Memory | A-width | E-width | E-costs
----+------------------------------------+--------+--------+--------+------------+-------------+---------+---------+------------------
1 | -> HashAggregate | 0.574 | 0 | 200 | | 29KB | | 8 | 396.113..398.113
2 | -> Hash Join (3,4) | 0.358 | 0 | 18915 | 200, 200 | 12KB | | 8 | 53.763..301.538
3 | -> Seq Scan on public.t1 | 0.037 | 1 | 1945 | | 22KB | | 8 | 0.000..29.450
4 | -> Hash | 0.038 | 0 | 1945 | | 264KB | | 8 | 29.450..29.450
5 | -> Seq Scan on public.t2 | 0.029 | 30 | 1945 | | 22KB | | 8 | 0.000..29.450
(5 rows)
Predicate Information (identified by plan id)
-----------------------------------------------
2 --Hash Join (3,4)
Hash Cond: (t1.c1 = t2.c2)
(2 rows)
Memory Information (identified by plan id)
--------------------------------------------------
1 --HashAggregate
Peak Memory: 29KB, Estimate Memory: 64MB
2 --Hash Join (3,4)
Peak Memory: 12KB, Estimate Memory: 64MB
3 --Seq Scan on public.t1
Peak Memory: 22KB, Estimate Memory: 64MB
4 --Hash
Peak Memory: 264KB
Buckets: 32768 Batches: 1 Memory Usage: 0kB
5 --Seq Scan on public.t2
Peak Memory: 22KB, Estimate Memory: 64MB
(11 rows)
Targetlist Information (identified by plan id)
------------------------------------------------
1 --HashAggregate
Output: sum(t2.c1), t1.c2
Group By Key: t1.c2
2 --Hash Join (3,4)
Output: t1.c2, t2.c1
3 --Seq Scan on public.t1
Output: t1.c1, t1.c2, t1.c3
4 --Hash
Output: t2.c1, t2.c2
5 --Seq Scan on public.t2
Output: t2.c1, t2.c2
(11 rows)
Datanode Information (identified by plan id)
----------------------------------------------------------------------------------------------------------
1 --HashAggregate
(actual time=0.574..0.574 rows=0 loops=1)
(Buffers: shared hit=2)
(CPU: ex c/r=0, ex row=0, ex cyc=527797, inc cyc=8385141377087373)
2 --Hash Join (3,4)
(actual time=0.358..0.358 rows=0 loops=1)
(Buffers: shared hit=2)
(CPU: ex c/r=-8385141375712241, ex row=1, ex cyc=-8385141375712241, inc cyc=8385141376559576)
3 --Seq Scan on public.t1
(actual time=0.037..0.037 rows=1 loops=1)
(Buffers: shared hit=1)
(CPU: ex c/r=8385141375728512, ex row=1, ex cyc=8385141375728512, inc cyc=8385141375728512)
4 --Hash
(actual time=0.038..0.038 rows=0 loops=1)
(Buffers: shared hit=1)
(CPU: ex c/r=0, ex row=0, ex cyc=-251554241295571040, inc cyc=8385141376543305)
5 --Seq Scan on public.t2
(actual time=0.019..0.029 rows=30 loops=1)
(Buffers: shared hit=1)
(CPU: ex c/r=8664646089070478, ex row=30, ex cyc=259939382672114336, inc cyc=259939382672114336)
(20 rows)
====== Query Summary =====
----------------------------------------
Datanode executor start time: 0.180 ms
Datanode executor run time: 0.590 ms
Datanode executor end time: 0.051 ms
Planner runtime: 0.366 ms
Query Id: 844424930141239
Total runtime: 0.866 ms
(6 rows)
上述示例中显示执行信息分为以下6个部分:
- 以表格的形式将计划显示出来,包含有11个字段,分别是:id、operation、A-time、A-rows、E-rows、E-distinct、Peak Memory、E-memory、A-width、E-width和E-costs。其中计划类字段(id、operation以及E开头字段)的含义与执行EXPLAIN时的含义一致,详见执行计划小节中的说明。A-time、A-rows、E-distinct、Peak Memory、A-width的含义说明如下:
- A-time:当前算子执行完成时间。
- A-rows:表示当前算子的实际输出元组数。
- E-distinct:表示hashjoin算子的distinct估计值。
- Peak Memory:此算子在执行时使用的内存峰值。
- A-width:表示当前算子每行元组的实际宽度,仅对于重内存使用算子会显示,包括:(Vec)HashJoin、(Vec)HashAgg、(Vec) HashSetOp、(Vec)Sort、(Vec)Materialize算子等,其中(Vec)HashJoin计算的宽度是其右子树算子的宽度,会显示在其右子树上。
- Predicate Information (identified by plan id):
- Memory Information (identified by plan id):
这一部分显示的是整个计划中会将内存的使用情况打印出来的算子的内存使用信息,主要是Hash、Sort算子,包括算子峰值内存(peak memory),控制内存(control memory),估算内存使用(operator memory),执行时实际宽度(width),内存使用自动扩展次数(auto spread num),是否提前下盘(early spilled),以及下盘信息,包括重复下盘次数(spill Time(s)),内外表下盘分区数(inner/outer partition spill num),下盘文件数(temp file num),下盘数据量及最小和最大分区的下盘数据量(written disk IO [min, max] )。
- Targetlist Information (identified by plan id):
- DataNode Information (identified by plan id):
- ====== Query Summary =====:
这一部分主要打印总的执行时间和网络流量,包括了初始化和结束阶段的最大最小执行时间,以及当前语句执行时系统可用内存、语句估算内存等信息。