### Broadcast
![[assets/ex_broadcast.png|256]]
### The Explain Trace
> [!NOTE]
> **Distributed Feature**: Broadcast nodes are found in distributed extensions like Citus. They do not appear in standard single-node PostgreSQL plans.
```sql
-- Conceptual plan for a distributed Join
-- (Table 'species' is broadcast to all nodes)
EXPLAIN SELECT * FROM animals a
JOIN species s ON a.species_id = s.id;
```
```text
Custom Scan (Citus Adaptive) (cost=1.00..1.00 rows=0 width=0)
-> Distributed Subplan 1
-> Broadcast (cost=1.00..2.05 rows=5 width=15)
-> Seq Scan on species s (...)
-> Task Executor
-> Index Scan using idx_animals_species_id on animals_102001 a (...)
```
---
- **Description**: Broadcast operations distribute data from one node to all other nodes in a distributed database system. This is often used in join operations where a small table is sent to all nodes to join with a larger, distributed table.
- **Performance**: Highly network-intensive; primarily used when the "broadcast" table is small enough to fit in the memory of every worker node.
- **Factors**: Size of the dataset being broadcast, network bandwidth, and the total number of nodes in the cluster.
- **Cost**: `network_transfer_cost * size_of_data * number_of_nodes`
![[assets/ex_broadcast_motion.svg|256]]
- **Operates on**: [[Structures/Result Set]]
- **Workloads**:
- [[Workloads/IPC/MessageQueue/MessageQueueSend|IPC: MessageQueueSend]]
- [[Workloads/IPC/MessageQueue/MessageQueueReceive|IPC: MessageQueueReceive]]
- [[Workloads/LWLock/Parallel/ParallelQueryDSA|LWLock: ParallelQueryDSA]]