internalsGet Pro

Module 08 · Lesson 9 of 14Pro

Joins at scale: broadcast and sort-merge

Level
Advanced
Topic
Batch processing with Spark
Reading time
17 min

When you finish this page you can

  1. Explain how Spark makes matching rows meet on one executor, by shuffling both sides or by copying one side everywhere.
  2. Estimate the bytes each join strategy moves, and say when a broadcast costs more than a shuffle.
  3. Read a physical plan to see which join Spark chose, and change the choice with a hint or a threshold.
  4. Predict when adaptive query execution switches a sort-merge join to a broadcast join at run time.
  1. Star and snowflake schemas18 min
  2. Shuffles: the most expensive step in Spark17 min
  3. Partitions and parallelism in Spark17 min

The join that worked on the sample

is an online store in India, now taking about 500,000 orders a day. Each night one of its Spark jobs, category_revenue_30d, turns the last 30 days of order lines into revenue by day, category and city. Daniel, who leads finance reporting, reads that table at 07:00.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan