Courseiva
Using Spark SQL →mediumMultiple Choice

Databricks-Spark-Assoc Using Spark SQL Practice Question

You are optimizing a Spark SQL query that performs a large join between a 10GB table and a 5MB lookup table. To ensure performance efficiency, which command should you use to hint to the optimizer?

⚠ Common exam trap

Students frequently rely entirely on the Catalyst optimizer to catch small tables, forgetting that certain complex expressions prevent automatic broadcasting.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

SELECT /*+ BROADCAST(t2) */ * FROM t1 JOIN t2

Spark SQL uses cost-based optimization, but small table broadcasts significantly reduce network shuffle overhead. By using the BROADCAST hint, you force the engine to send the small table to every executor, avoiding a full shuffle of the 10GB dataset. This is a critical optimization technique in Databricks environments where minimizing cross-node data movement is essential for reducing total job latency and improving cluster resource utilization.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    SELECT /*+ MERGE(t1, t2) */ * FROM t1 JOIN t2

    Why it's wrong here

    The MERGE hint is specifically intended for merge joins, which are typically used when joining large datasets that are already sorted or partitioned. It does not instruct the optimizer to replicate small tables across the cluster, failing to address the specific performance bottleneck associated with joining small lookup tables against large ones.

  • ✗

    SELECT /*+ SHUFFLE(t1, t2) */ * FROM t1 JOIN t2

    Why it's wrong here

    The SHUFFLE hint forces a shuffle-based join strategy, which is the exact opposite of what is required here. Forcing a shuffle when one table is small enough to fit in memory increases network traffic unnecessarily, resulting in significantly higher latency compared to an efficient broadcast join operation.

  • ✓

    SELECT /*+ BROADCAST(t2) */ * FROM t1 JOIN t2

    Why this is correct

    The BROADCAST hint explicitly instructs the Spark catalyst optimizer to perform a broadcast hash join. By duplicating the smaller table to all executors, Spark eliminates the need for expensive wide transformations and data reshuffling, allowing the join to occur locally within each task, which maximizes performance for this specific scenario.

  • ✗

    SELECT /*+ SKEW(t1) */ * FROM t1 JOIN t2

    Why it's wrong here

    The SKEW hint is used to handle data skew by splitting skewed partitions into smaller tasks. It does not improve performance for a simple small-to-large table join unless the large table itself contains highly unevenly distributed keys, making it irrelevant for this optimization task involving a small lookup table.

About these practice questions

This Databricks-Spark-Assoc question is part of Courseiva's 295-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Databricks exam blueprint

This Databricks-Spark-Assoc practice question is part of Courseiva's free Databricks certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the Databricks-Spark-Assoc exam.