Skip to content
About
Main content

Broadcast, shuffle and runtime filters

When does a runtime filter earn its barrier?

Broadcast, shuffle, and the partitioning you already have

A repartitions both inputs by the hash of the join key, then runs a local join on each . The network cost is roughly |R| + |S| (each row moves once). The payoff is that per-node build memory becomes build/P. Dividing the memory problem by the parallelism is the whole point.

A copies the small side to all P nodes. The network cost is |S_small|·P. The large side never moves and, importantly, it keeps its partitioning. A later or join on the same key then also avoids a shuffle. Property preservation compounds down the plan; a local cost saving does not.

The network break-even is |S_small|·P < |R| + |S_small|. This reduces to: broadcast when the size ratio exceeds the parallelism (|R| / |S_small| > P roughly).

the large input
the small input (copied to every node)
nodes
broadcastshuffle
Data table
Bytes over the network by parallelism (R = 400 GB, S = 500 MB)
Parallelism PseriesBytes moved
10broadcast4.66 GB
10.8broadcast5.03 GB
11.7broadcast5.44 GB
12.6broadcast5.88 GB
13.6broadcast6.35 GB
14.7broadcast6.87 GB
15.9broadcast7.42 GB
17.2broadcast8.02 GB
18.6broadcast8.67 GB
20.1broadcast9.37 GB
21.7broadcast10.1 GB
23.5broadcast10.9 GB
25.4broadcast11.8 GB
27.5broadcast12.8 GB
29.7broadcast13.8 GB
32.1broadcast14.9 GB
34.7broadcast16.1 GB
37.5broadcast17.4 GB
40.5broadcast18.9 GB
43.8broadcast20.4 GB
47.3broadcast22 GB
51.1broadcast23.8 GB
55.2broadcast25.7 GB
59.7broadcast27.8 GB
64.5broadcast30 GB
69.7broadcast32.5 GB
75.4broadcast35.1 GB
81.5broadcast37.9 GB
88broadcast41 GB
95.1broadcast44.3 GB
103broadcast47.9 GB
111broadcast51.8 GB
120broadcast55.9 GB
130broadcast60.4 GB
140broadcast65.3 GB
152broadcast70.6 GB
164broadcast76.3 GB
177broadcast82.5 GB
191broadcast89.1 GB
207broadcast96.3 GB
224broadcast104 GB
242broadcast113 GB
261broadcast122 GB
282broadcast131 GB
305broadcast142 GB
330broadcast154 GB
356broadcast166 GB
385broadcast179 GB
416broadcast194 GB
450broadcast210 GB
486broadcast226 GB
526broadcast245 GB
568broadcast264 GB
614broadcast286 GB
663broadcast309 GB
717broadcast334 GB
775broadcast361 GB
838broadcast390 GB
905broadcast422 GB
978broadcast456 GB
1.06Kbroadcast492 GB
1.14Kbroadcast532 GB
1.24Kbroadcast575 GB
1.33Kbroadcast622 GB
1.44Kbroadcast672 GB
1.56Kbroadcast726 GB
1.69Kbroadcast785 GB
1.82Kbroadcast848 GB
1.97Kbroadcast917 GB
2.13Kbroadcast991 GB
2.3Kbroadcast1.05 TB
2.49Kbroadcast1.13 TB
2.69Kbroadcast1.22 TB
2.9Kbroadcast1.32 TB
3.14Kbroadcast1.43 TB
3.39Kbroadcast1.54 TB
3.66Kbroadcast1.67 TB
3.96Kbroadcast1.8 TB
4.28Kbroadcast1.95 TB
4.63Kbroadcast2.1 TB
5Kbroadcast2.27 TB
10shuffle373 GB
10.8shuffle373 GB
11.7shuffle373 GB
12.6shuffle373 GB
13.6shuffle373 GB
14.7shuffle373 GB
15.9shuffle373 GB
17.2shuffle373 GB
18.6shuffle373 GB
20.1shuffle373 GB
21.7shuffle373 GB
23.5shuffle373 GB
25.4shuffle373 GB
27.5shuffle373 GB
29.7shuffle373 GB
32.1shuffle373 GB
34.7shuffle373 GB
37.5shuffle373 GB
40.5shuffle373 GB
43.8shuffle373 GB
47.3shuffle373 GB
51.1shuffle373 GB
55.2shuffle373 GB
59.7shuffle373 GB
64.5shuffle373 GB
69.7shuffle373 GB
75.4shuffle373 GB
81.5shuffle373 GB
88shuffle373 GB
95.1shuffle373 GB
103shuffle373 GB
111shuffle373 GB
120shuffle373 GB
130shuffle373 GB
140shuffle373 GB
152shuffle373 GB
164shuffle373 GB
177shuffle373 GB
191shuffle373 GB
207shuffle373 GB
224shuffle373 GB
242shuffle373 GB
261shuffle373 GB
282shuffle373 GB
305shuffle373 GB
330shuffle373 GB
356shuffle373 GB
385shuffle373 GB
416shuffle373 GB
450shuffle373 GB
486shuffle373 GB
526shuffle373 GB
568shuffle373 GB
614shuffle373 GB
663shuffle373 GB
717shuffle373 GB
775shuffle373 GB
838shuffle373 GB
905shuffle373 GB
978shuffle373 GB
1.06Kshuffle373 GB
1.14Kshuffle373 GB
1.24Kshuffle373 GB
1.33Kshuffle373 GB
1.44Kshuffle373 GB
1.56Kshuffle373 GB
1.69Kshuffle373 GB
1.82Kshuffle373 GB
1.97Kshuffle373 GB
2.13Kshuffle373 GB
2.3Kshuffle373 GB
2.49Kshuffle373 GB
2.69Kshuffle373 GB
2.9Kshuffle373 GB
3.14Kshuffle373 GB
3.39Kshuffle373 GB
3.66Kshuffle373 GB
3.96Kshuffle373 GB
4.28Kshuffle373 GB
4.63Kshuffle373 GB
5Kshuffle373 GB

The network arithmetic permits far larger broadcasts than any engine allows, because two other costs bind first:

  • The small side must be resident on every , so the memory used is |S_small|·P.
  • The is built P times instead of once, so the total build CPU is P× higher.

So the claim "broadcasting a small table is always free" is wrong. With P in the hundreds, a 500 MB broadcast is 100 GB of cluster memory and a hundred or more redundant builds. In engines that route the broadcast through a central driver process, it is also a serialization point that fails hard instead of slowly.

The third option costs nothing at run time: both tables pre-partitioned on the join key at write time (bucketing, , a shared DISTRIBUTED BY clause). The network cost is zero. Its price is paid where you do not see it:

  • every other query is now partitioned on a key it does not want;
  • the bucket counts on both sides must match or divide evenly;
  • any rewrite of either table that changes the bucketing silently invalidates the plan.

It is the highest-leverage and the most brittle option in this article.


Sideways information passing: move the summary, not the rows

The idea: send a compact description of the 's keys to the probe side's scan before the probe side moves any data, and discard non-matching rows at the source. In practice this is a runtime filter, usually a Bloom filter.

Its leverage is the ratio of the filter's size (about 10 bits per key) to the rows it keeps from moving (often hundreds of bytes each), and its cost is that the filter must exist before the probe side is scanned, a barrier between two pipelines that were independent. How big to make the filter, which kind to build (min/max, IN-list or Bloom) and when it earns its barrier are the planner's decision (Dynamic partition pruning and runtime filters). On the join side, what matters is what the filter does to correctness.

Why the approximation is safe here. A 's false positives let a few non-matching rows through. But an exact join follows the filter, so those rows are removed later. False positives cost work, not correctness. This is the general safe pattern: Compare approximate aggregation in Aggregation algorithms, where the approximation is in the answer itself. Same mathematics, very different risk.