A daily aggregation over a Delta table runs on a cluster providing 32 cores in total. In the Spark UI the stage that reads the shuffle reports 8,000 tasks, a median task shuffle read of 3 MB, a maximum of 4 MB, no spill recorded, and a median task duration under one second, while the stage itself takes fourteen minutes from start to finish. The cluster inherits a Spark configuration from an older workload, in which spark.sql.shuffle.partitions is set to 8000 and spark.sql.adaptive.enabled is set to false. Which change addresses the cause of that stage duration?
spark.sql.shuffle.partitions 8000
spark.sql.adaptive.enabled false- ARaise spark.sql.shuffle.partitions to 16000, so that the stage divides its work across more tasks and makes fuller use of the cores already available on the cluster.
- BSet spark.sql.adaptive.enabled to true, so that adaptive partition coalescing merges the small post shuffle partitions into fewer and larger tasks while the query is running. Correct
- CSet spark.sql.adaptive.skewJoin.enabled to true, so that the oversized partitions in the stage are split into smaller ones and spread over cores that are otherwise idle.
- DDouble the cluster to 64 cores, so that twice as many of the 8,000 tasks are in flight at once and the stage finishes in roughly half of its present duration.
Why A is wrong: It is tempting because more partitions usually means more parallelism, but the partition count already exceeds the core count by a factor of 250, so doubling it doubles the scheduling and shuffle block bookkeeping that is producing the fourteen minutes.
Why B is correct: Adaptive query execution reads the shuffle statistics after the map side finishes, and with spark.sql.adaptive.coalescePartitions.enabled at its default it combines the tiny partitions into a task count suited to the data volume and the cluster.
Why C is wrong: Skew handling is a reasonable reflex when a stage runs long, but the reported median of 3 MB and maximum of 4 MB show an even distribution with no oversized partition to split, and that setting has no effect while adaptive query execution is switched off.
Why D is wrong: Adding hardware looks attractive because the tasks queue behind the available cores, but it treats the symptom and leaves the per task overhead untouched, so the run costs twice as much for a much smaller improvement than the arithmetic suggests.