Why More Executors Don't Always Make Spark Faster: Understanding AQE
Learn how Spark Adaptive Query Execution addresses data skew, small shuffle partitions, and inefficient join strategies using runtime statistics.
When a Spark job runs long, one of the easiest fixes to reach for is more compute. The instinct is understandable: if the cluster is busy, give it more workers and more memory. The problem is that a slow Spark job is not always a capacity problem. Sometimes the cluster has plenty of resources, but the work is divided badly, or the original query plan no longer matches the data that actually shows up at runtime.
A familiar example is a stage with 200 tasks where 199 finish in roughly 20 seconds and one task runs for several minutes. The job is not waiting because the cluster needs 20 more executors. It is waiting because one task received far more work than the rest. The opposite can happen too: Spark may create hundreds of tiny tasks, each processing only a few megabytes, so scheduling overhead becomes noticeable. Joins introduce another variation: Spark can choose a reasonable strategy before execution, then discover after filtering that one side of the join is much smaller than expected.
Adaptive Query Execution (AQE) is useful in all three situations because it lets Spark reconsider parts of the physical plan using information collected while the query is running. The feature matters less as a checkbox and more as a change in how we troubleshoot Spark: instead of asking only how much compute a job needs, we first ask what is actually making the job slow.
What AQE Actually Does
Spark creates a physical plan before it executes a SQL query or DataFrame operation. That plan includes choices such as the join method, the number of shuffle partitions, and how data should move between executors. Those choices are based on statistics and estimates available at planning time. They are often good enough, but they are still estimates.
Once execution begins, Spark learns things that were impossible to know precisely beforehand. A filter may reduce a large table to a small intermediate result. A shuffle may produce many tiny partitions. One key may create a partition several times larger than the others. AQE uses those runtime statistics to adjust work that has not yet executed.
A useful analogy is a GPS route. You start with the best route available, but if traffic conditions change or new information arrives, the GPS adjusts the remaining path. It cannot undo the road already traveled; it can only improve what comes next. AQE works the same way around materialized query stages.

Figure 1. Spark starts with an estimated plan, collects runtime statistics, and can revise later stages when the real data differs from the estimate.
Problem 1: One Task Is Much Slower Than the Rest
One of the clearest Spark performance symptoms is a stage that looks almost finished but refuses to complete. Most tasks are green, CPU usage may already be falling, yet one task keeps running. This is usually a better clue than the total job duration.
At this point, adding executors is not the first thing to try. The useful question is why the last task has so much more work. A common cause is data skew.
What Data Skew Looks Like
Spark processes data in partitions. Parallel execution works best when those partitions contain roughly similar amounts of work. A balanced shuffle might produce partitions around 180-210 MB each. A skewed shuffle can look very different:

The fourth partition is the outlier. While several executors finish their 200 MB tasks, one executor still has gigabytes left to process. That is why a Spark UI can show free CPU even though the stage has not completed. The bottleneck is not lack of workers; it is the shape of the work.
Skew often comes from a small number of very frequent keys: a default identifier, an unknown category, a null-like value, or simply a naturally popular key. Nothing has to be 'wrong' with the data for skew to exist.
How AQE Helps With Skew
After a shuffle materializes, Spark knows the actual size of the resulting partitions. For supported joins, AQE can identify an oversized partition and split that work into smaller pieces before later tasks run.


Figure 2. Before AQE, one oversized partition creates a straggler. Adaptive skew handling can split the work into smaller pieces so more tasks can progress in parallel.
What to Check in the Spark UI
When a stage seems stuck near completion, compare tasks rather than relying on the average. Look at the longest task, its shuffle read size, and whether it spilled much more data than the others. Spill occurs when Spark cannot keep all of an operation's intermediate data in memory and has to use disk.

This is a more useful diagnosis than simply saying that the job took 30 minutes. It tells you where to look next.
A Practical Skew Investigation
Consider a stage with 240 tasks. The first 239 finish in about 25 seconds, while the final task runs for more than six minutes. At first glance, the cluster can look underpowered because the stage is still active. But the task metrics tell a different story: most tasks read between 150 and 220 MB of shuffle data, while the straggler reads 5.6 GB and spills heavily to disk.
In that situation, increasing the executor count is unlikely to be the first useful move. The other executors have already finished their work. The better next step is to inspect the key distribution and the final adaptive plan. If AQE marks the join as skewed and splits that oversized partition, the bottleneck was work distribution rather than raw cluster capacity.
Problem 2: Spark Creates Too Many Small Tasks
The opposite failure mode is less dramatic but surprisingly common: instead of one task doing too much, Spark schedules hundreds or thousands of tasks that do almost nothing. The query is still correct, but the amount of coordination starts to compete with the useful work.

Every task has overhead. Spark has to schedule it, an executor has to start it, shuffle blocks may need to be fetched, and the driver has to track progress. When each task processes only a tiny amount of data, those fixed costs become noticeable.
Why More Partitions Are Not Always Better
It is tempting to treat partition count as a simple parallelism dial: more partitions should mean more workers can run at once. That is true only up to a point. Too few partitions create large tasks that may spill or run for a long time. Too many partitions create tiny tasks and unnecessary scheduling overhead.
A single fixed value is also hard to justify when the same workload changes from day to day. A query might process 30 GB on Monday, 15 GB on Wednesday, and 180 GB at month end. A partition count that feels sensible for 180 GB can be wasteful for 15 GB.
How AQE Coalesces Small Shuffle Partitions
Once the shuffle has finished, Spark knows how much data each output partition actually contains. AQE can combine adjacent small partitions before the next stage begins. The exact grouping depends on the workload and configuration, but the idea is simple:

Spark is no longer forced to carry the original shuffle partition count into the next stage when the data proves that many of those partitions are unnecessarily small.
A Practical Over-Partitioning Example
Imagine a daily aggregation configured with 2,000 shuffle partitions because month-end runs can be very large. On an ordinary weekday, filters reduce the input so aggressively that the next stage receives only a few gigabytes. The Spark UI then shows hundreds of tasks completing in well under a second. Nothing is technically broken, but the stage spends a noticeable amount of time creating, scheduling, and tracking work that contains very little data.
That is a good case for checking whether AQE coalesced the post-shuffle partitions. If the final adaptive plan shows fewer, larger shuffle reads, Spark is matching the task count to the data that actually arrived rather than blindly preserving the original partition count.
Problem 3: The Original Join Strategy Becomes Expensive
Joins are where planning-time estimates become especially visible. Suppose Dataset A is large and Dataset B is estimated at 150 MB. Spark may reasonably choose a sort-merge join, which can involve shuffling and sorting both sides.

Now assume Dataset B has a selective filter. After that stage runs, the intermediate result is only 7 MB. The physical problem is no longer the one Spark planned for.
Broadcast Join in Simple Terms
When one side of a join is small enough, Spark can send a copy of that small relation to the workers processing the large dataset. Each worker can then perform the join locally instead of redistributing both sides across the cluster.

Broadcast is not automatically better for every join, but it can avoid significant shuffle and sort work when one side is genuinely small.
Where AQE Helps
The planner may have seen 150 MB before execution. After filtering, AQE can see that the actual intermediate result is 7 MB. If the runtime conditions support it, the remaining plan can switch from a sort-merge join to a broadcast hash join.

The SQL did not change. The underlying table did not change in the middle of the job. What changed was Spark's knowledge about the data reaching the join.
A Practical Join Example
Suppose a reference table is usually large enough that a sort-merge join is a sensible choice. A particular report, however, filters that table to a narrow date range and a small set of categories. The planning estimate still makes the relation look substantial, but after the filter runs the materialized result is only a few megabytes.
If the final adaptive plan changes the join to a broadcast hash join, that is evidence that runtime information changed the economics of the query. This is more useful than simply saying that AQE 'made the job faster': it explains which assumption changed and why a different strategy became reasonable.
Good Statistics Still Matter
AQE does not make table statistics irrelevant. A good initial plan is still better than correcting an avoidable mistake later. The challenge is that stored table statistics describe source data more easily than they predict every intermediate result after several filters and transformations.

The source table is large; the relation entering the next operator is not. AQE helps because that second number becomes known only after part of the query has actually run.
How the Three Problems Look Different
The most useful Spark tuning skill is not memorizing every AQE setting. It is learning to recognize the pattern in front of you.
|
What you notice |
What to investigate |
|
One task runs much longer than the others |
Data skew or an oversized partition |
|
One task reads far more shuffle data |
Data skew |
|
Hundreds of tasks finish almost immediately |
Too many small post-shuffle partitions |
|
A join produces a large shuffle |
Join strategy and input sizes |
|
One join side becomes tiny after filtering |
Whether broadcast becomes practical |
|
Most time is spent reading source files |
Storage layout, pruning, or scan cost before AQE |
|
Most tasks spill heavily |
Tasks may be too large or memory pressure may exist |
Initial Plan vs. Final Plan
With AQE, a pre-execution physical plan is only the first version of the story. The initial plan tells you what Spark expected to do. The final adaptive plan tells you what it decided after seeing runtime statistics.

That difference is useful evidence. It shows that the runtime data materially changed the execution strategy. The same idea applies when AQE coalesces shuffle partitions or handles a skewed join.
Why EXPLAIN Does Not Tell the Whole Story
`EXPLAIN` is valuable because it shows the plan Spark currently expects to use. The limitation is that AQE depends on runtime information. A pre-execution explain plan cannot contain statistics from stages that have not run yet.
For AQE troubleshooting, use both views: the plan before execution and the executed/final adaptive plan together with Spark UI metrics. One shows the assumption; the other shows what actually happened.
A Simple Troubleshooting Process
If a Spark workload takes 30 minutes, resist the urge to start by changing configuration. A short diagnostic pass usually gives you a much better target.
- Find the slowest stage: Identify where most of the job time is concentrated. If one stage accounts for 20 of the 30 minutes, start there.
- Look at the tasks inside that stage: Compare median and maximum task time. One extreme task suggests a very different problem from thousands of tiny tasks.
- Inspect shuffle data: Large shuffle read/write values point toward joins, aggregations, partition sizing, or skew.
- Look at the join strategy: If the expensive stage contains a join, compare the chosen strategy with the actual input sizes that materialized.
- Compare the initial and final plans: Check whether AQE coalesced partitions, handled skew, or changed a join strategy.
- Tune only after identifying the bottleneck: Now a configuration change has a specific reason behind it instead of being a guess.
What Not to Do Automatically
Several common Spark tuning actions are perfectly reasonable when they match the problem. They become expensive trial-and-error when they are used as defaults.
- Adding executors helps when the workload has enough independent work to use them. It may do little when one skewed task is the bottleneck.
- Increasing shuffle partitions can help when tasks are too large, but it can make scheduling overhead worse when the stage already contains many tiny tasks.
- Forcing a broadcast join can be effective when one relation is reliably small, but it can be risky when that relation varies significantly between runs.
- Using one partition count for every workload is operationally simple, but it ignores differences in data volume and distribution.
The configuration value is rarely the diagnosis. The useful part is knowing which behavior you are trying to change.
What AQE Cannot Fix
AQE is helpful, but it is not a substitute for good data engineering. If a query reads 2 TB when it only needs 50 GB, AQE does not remove the unnecessary scan. If a table contains thousands of badly sized files, AQE does not redesign the storage layout. It will not rewrite inefficient business logic or make two genuinely huge join inputs magically small enough to broadcast.
Good filtering, file layout, table design, statistics, and query structure still matter. AQE adds resilience when runtime conditions differ from planning-time assumptions; it does not make those fundamentals optional.
A Better Way to Think About Spark Performance
A common troubleshooting pattern is 'slow job -> add more compute.' A more reliable sequence is to narrow the problem before deciding what to change.

This approach takes a few extra minutes before the first configuration change, but it usually saves much more time than repeatedly resizing the cluster and rerunning the job.
Conclusion
A slow Spark job does not automatically mean the cluster is too small. One task may have received far more data than the others. A shuffle may have produced hundreds of tiny tasks. A join strategy may have been chosen using an estimate that no longer matches the filtered data.
AQE helps because Spark can react to some of these conditions after execution begins. It can coalesce small shuffle partitions, split certain skewed join partitions, and change some join strategies when runtime relation sizes make a better option possible.
The larger lesson is about diagnosis, not a single Spark feature. Start with the slow stage. Look at the task distribution. Check shuffle and spill. Inspect the join. Then compare the initial plan with the final adaptive plan. Once you know what Spark learned at runtime, the tuning decision is usually much easier to justify.
In practice, this also prevents a common tuning trap: changing several settings at once and then not knowing which change mattered. A small amount of observation up front usually makes the eventual fix easier to explain, repeat, and defend.
Opinions expressed by DZone contributors are their own.