更新时间:2025-05-29 GMT+08:00

Streaming

算子说明

当SQL语句不能下推时,会优先生成分布式执行计划。Streaming共有三种形态,分别对应了分布式结构下不同的数据shuffle功能:
  • Streaming(type: GATHER):作用是coordinator从DN收集数据。
  • Streaming(type: REDISTRIBUTE):作用是DN根据选定的列把数据重分布到所有的DN
  • Streaming(type: BROADCAST):作用是把当前DN的数据广播给其他所有的DN

典型场景

分布式执行计划

示例

--准备数据。
gaussdb=# DROP TABLE IF EXISTS t1;
gaussdb=# DROP TABLE IF EXISTS t2;
gaussdb=# CREATE TABLE t1(c1 int, c2 int);
gaussdb=# CREATE TABLE t2(c1 int, c2 int);

--执行结果。
gaussdb=# EXPLAIN SELECT * FROM t1,t2 WHERE t1.c2 = t2.c2;
                                 QUERY PLAN
----------------------------------------------------------------------------
 Streaming (type: GATHER)  (cost=13.92..29.57 rows=20 width=16)
   Node/s: All datanodes
   ->  Hash Join  (cost=13.29..28.64 rows=20 width=16)
         Hash Cond: (t1.c2 = t2.c2)
         ->  Streaming(type: BROADCAST)  (cost=0.00..15.18 rows=40 width=8)
               Spawn on: All datanodes
               ->  Seq Scan on t1  (cost=0.00..13.13 rows=20 width=8)
         ->  Hash  (cost=13.13..13.13 rows=21 width=8)
               ->  Seq Scan on t2  (cost=0.00..13.13 rows=20 width=8)
(9 rows)

--删除。
gaussdb=# DROP TABLE IF EXISTS t1;
gaussdb=# DROP TABLE IF EXISTS t2;

信息名称

含义

Streaming

算子的名称。

Spawn on: All datanodes

表示会分发到所有DN