> [!NOTE] Redistribute > <table> > <tr> > <td width="25%"><img src="assets/ex_redistribute.png"></td> > <td>A distributed execution node (often in Citus or other distributed extensions) that reshuffles data across the network. Rows are moved between worker nodes so that they can be joined or aggregated locally by their distribution keys.</td> > </tr> > </table> > > ```sql > -- The tables are distributed on account_id and user_id, but this join uses > -- alternate_key, forcing a real Citus repartition join. > SET LOCAL citus.explain_all_tasks = false; > SET LOCAL citus.enable_repartition_joins = true; > EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE, SETTINGS) > SELECT count(*) > FROM audit_events e > JOIN audit_actions a > ON e.alternate_key = a.alternate_key; > ``` > > ![Redistribute Plan Tree](assets/plan_tree_op_redistribute.svg) > > ```text > Aggregate (cost=250.00..250.02 rows=1 width=8) (actual time=1003.421..1003.438 rows=1.00 loops=1) > Output: COALESCE((pg_catalog.sum(remote_scan.count))::bigint, '0'::bigint) > Buffers: shared hit=79 > -> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=100000 width=8) (actual time=1002.416..1002.429 rows=12.00 loops=1) > Output: remote_scan.count > Task Count: 12 > Tuple data received from nodes: 96 bytes > Tasks Shown: None, not supported for re-partition queries > -> MapMergeJob > Map Task Count: 4 > Merge Task Count: 12 > -> MapMergeJob > Map Task Count: 4 > Merge Task Count: 12 > Buffers: shared hit=79 > Settings: enable_self_join_elimination = 'off' > Planning: > Buffers: shared hit=513 > Planning Time: 28.862 ms > Execution Time: 1005.433 ms > ``` > > <table> > <tr> > <td rowspan="2" width="25%"><img src="assets/ex_redistribute_motion.svg"></td> > <td><b>Performance</b></td><td>Extremely network and CPU-intensive; often the primary bottleneck in large-scale distributed joins.</td> > </tr> > <tr><td><b>Conceptual cost</b></td><td><code>network_transfer_cost * data_size + cpu_cost * data_size</code>; the literal Citus plan reports the map/merge task topology instead of a standalone redistribution-node cost.</td></tr> > </table>