Back to questions
JuniorTheoryCommon
What do Gather, Redistribute and Broadcast Motion, and slices, mean in a Greenplum EXPLAIN plan?
A motion moves rows between segments over the interconnect: Gather sends results to the coordinator, Redistribute rehashes rows to segments by a key, Broadcast copies every row to all segments. Motions cut the plan into slices that run in parallel.
- Reading a Redistribute or Broadcast Motion as free, when it means rows crossing the network before the next step
- Overlooking a Broadcast Motion over a large table, which copies all of it to every segment
- Treating the final Gather Motion as a problem, though every query that returns rows to the client ends with one
- When would the planner choose to broadcast one side of a join rather than redistribute both?
- What does a
48:1or48:48after a motion name tell you?
Reading a Greenplum plan (Arenadata DB and Greengage DB plans look the same). orders is distributed by order_id, customers by customer_id, on a 48-segment cluster:
Gather Motion 48:1 (slice2; segments: 48)
-> HashAggregate
Group Key: c.customer_id
-> Hash Join
Hash Cond: (o.customer_id = c.customer_id)
-> Redistribute Motion 48:48 (slice1; segments: 48)
Hash Key: o.customer_id
-> Seq Scan on orders o
-> Hash
-> Seq Scan on customers c- Redistribute Motion 48:48 — each of the 48 segments rehashes its
ordersrows oncustomer_idand sends them to the segment that owns that hash. Afterwards each order sits next to its customer, and the join runs locally.customersdoes not move: it is already distributed on the join key. - Broadcast Motion would appear if the planner chose to send a small table in full to every segment. For a lookup table that is cheap; for a table of hundreds of millions of rows every row is multiplied by the segment count.
- Gather Motion 48:1 — the segments send the result to the coordinator. Every query that returns rows to the client ends with one.
- Slices. A motion is a boundary: everything below it down to the next motion is one slice, which each segment runs with its own group of processes. Here slice 1 scans and ships
orders, slice 2 receives the rows, joins and aggregates, and the coordinator gathers the result.
Every Redistribute or Broadcast is rows crossing the network, so a warehouse plan is read by its motions first: which table moves, how many rows, and why its distribution key did not match the join key.