> [!NOTE] Broadcast > <table> > <tr> > <td width="25%"><img src="assets/ex_broadcast.png"></td> > <td>A distributed optimization where the engine copies an entire (usually small) relation to every worker node in the cluster. This allows large distributed tables to be joined with small reference tables without moving the large data set.</td> > </tr> > </table> > > ```sql > -- Citus 14.1: materialize a small distributed result, then send it to > -- both workers for the outer distributed query. > SET LOCAL citus.explain_all_tasks = false; > EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE, SETTINGS) > SELECT e.account_id, count(*) > FROM audit_events e > WHERE e.alternate_key IN ( > SELECT a.alternate_key > FROM audit_actions a > GROUP BY a.alternate_key > ORDER BY count(*) DESC > LIMIT 5 > ) > GROUP BY e.account_id > ORDER BY e.account_id > LIMIT 10; > ``` > > ![Broadcast Plan Tree](assets/plan_tree_op_broadcast.svg) > > <table> > <tr> > <td rowspan="2" width="25%"><img src="assets/ex_broadcast_motion.svg"></td> > <td><b>Performance</b></td><td>Highly network-intensive; primarily used when the "broadcast" table is small enough to fit in the memory of every worker node.</td> > </tr> > <tr><td><b>Conceptual cost</b></td><td><code>network_transfer_cost * size_of_data * number_of_nodes</code>; Citus reports the actual intermediate-data size and destination rather than a standalone broadcast-node cost.</td></tr> > </table>