<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Data_skew</id>
	<title>Data skew - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Data_skew"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Data_skew&amp;action=history"/>
	<updated>2026-12-06T00:08:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://openlakehouse.io/w/index.php?title=Data_skew&amp;diff=138&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@7c9abaa</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Data_skew&amp;diff=138&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:39Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@7c9abaa&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox concept&lt;br /&gt;
| name            = Data skew&lt;br /&gt;
| also_known_as   = Skew, hot keys, partition skew&lt;br /&gt;
| field           = Distributed data processing&lt;br /&gt;
| key_parts       = Uneven [[partition]] sizes, straggler tasks, hot keys&lt;br /&gt;
| implementations = [[Apache Spark]] (AQE skew join), [[Apache Flink]] (adaptive skewed join, local-global aggregation), [[Trino]]&lt;br /&gt;
| related         = [[Shuffle]], [[Salting]], [[Adaptive Query Execution]], [[Spill (memory)]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (docs/sql-performance-tuning.md, docs/web-ui.md, docs/sql-ref-syntax-qry-select-hints.md, adaptive/OptimizeSkewedJoin.scala), SPARK-29544, the Apache Flink 2.3 docs (Adaptive Batch, Performance Tuning) and the Trino 484 docs}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Data skew&amp;#039;&amp;#039;&amp;#039; is an uneven distribution of data across the [[partition]]s of a distributed computation, so that a few tasks process far more data than the rest and the whole stage waits for them. In [[Apache Spark]], skew usually appears after a [[shuffle]], when many rows share the same join or grouping key and all land in one task. Spark&amp;#039;s [[Adaptive Query Execution]] (AQE) splits skewed join partitions automatically; other cases need manual fixes such as [[salting]].&amp;lt;ref name=&amp;quot;perf&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/sql-performance-tuning.html |title=Performance Tuning (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to recognize data skew in the Spark UI ==&lt;br /&gt;
Data skew shows up as a gap between the typical task and the slowest task in one stage. The Spark UI stage page shows summary metrics for all tasks of a stage, including task duration, GC time, shuffle read size and records, and shuffle spill.&amp;lt;ref name=&amp;quot;webui&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/web-ui.html |title=Web UI (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; A skewed stage has a maximum duration and shuffle read size many times the median. The REST API returns the same summary as quantiles, by default 0.0, 0.25, 0.5, 0.75 and 1.0, and accepts other quantiles such as &amp;lt;code&amp;gt;?quantiles=0.01,0.5,0.99&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;monitoring&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/monitoring.html |title=Monitoring and Instrumentation (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other signs of skew in the Spark UI are spill or high GC time in only the largest tasks, which the per-task table on the same page shows, and a stage that sits at a few running tasks long after most have finished.&amp;lt;ref name=&amp;quot;webui&amp;quot; /&amp;gt; See [[Spill (memory)]] and [[Garbage collection in Spark]].&lt;br /&gt;
&lt;br /&gt;
== What causes data skew? ==&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Hot keys.&amp;#039;&amp;#039;&amp;#039; A join or &amp;lt;code&amp;gt;GROUP BY&amp;lt;/code&amp;gt; key with one very common value (a default customer ID, a popular product, &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt;) sends all of its rows to one shuffle partition, because a shuffle brings all the values for a key together in one place (&amp;lt;code&amp;gt;hashpartitioning&amp;lt;/code&amp;gt; in the plan).&amp;lt;ref name=&amp;quot;rddguide&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/rdd-programming-guide.html#shuffle-operations |title=RDD Programming Guide: Shuffle operations (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Skewed source files.&amp;#039;&amp;#039;&amp;#039; Uneven input files or table partitions give some scan tasks much more data than others. See [[Small files problem]].&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Partitioning that does not match the data.&amp;#039;&amp;#039;&amp;#039; Repartitioning by a low-cardinality column puts many rows in few partitions.&lt;br /&gt;
&lt;br /&gt;
== How Spark handles skew: AQE skew join ==&lt;br /&gt;
Spark 3.0.0 added a skew join rule to the new AQE framework.&amp;lt;ref name=&amp;quot;spark29544&amp;quot;&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-29544 |title=SPARK-29544: Optimize skewed join at runtime with new Adaptive Execution |publisher=Apache Software Foundation JIRA |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; After the shuffle stages on both sides of a join have run, AQE checks partition sizes. A partition is skewed when it is larger than &amp;lt;code&amp;gt;spark.sql.adaptive.skewJoin.skewedPartitionFactor&amp;lt;/code&amp;gt; (default 5.0) times the median partition size and also larger than &amp;lt;code&amp;gt;spark.sql.adaptive.skewJoin.skewedPartitionThresholdInBytes&amp;lt;/code&amp;gt; (default 256 MB). AQE splits such a partition into several tasks, replicating the matching partition of the other side.&amp;lt;ref name=&amp;quot;perf&amp;quot; /&amp;gt; The feature is on by default (&amp;lt;code&amp;gt;spark.sql.adaptive.skewJoin.enabled&amp;lt;/code&amp;gt;) whenever AQE is on, and AQE is on by default since Spark 3.2.0.&amp;lt;ref name=&amp;quot;perf&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
AQE can split only the sides that the join type allows. In Spark 4.3.0 it can split the left side of inner, cross, left semi, left anti and left outer joins, and the right side of inner, cross and right outer joins; it applies to sort-merge and shuffled hash joins.&amp;lt;ref name=&amp;quot;skewrule&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/OptimizeSkewedJoin.scala |title=OptimizeSkewedJoin.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Full outer joins and skewed aggregations are not split by this rule; for those, [[salting]] or a two-stage aggregation is still used.&lt;br /&gt;
&lt;br /&gt;
For writes, the &amp;lt;code&amp;gt;REBALANCE&amp;lt;/code&amp;gt; hint asks AQE to even out output partitions and to split skewed ones, which keeps very large files out of a [[Delta Lake]] or [[Apache Iceberg]] table.&amp;lt;ref name=&amp;quot;hints&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/sql-ref-syntax-qry-select-hints.html |title=Hints (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;perf&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
spark.sql.adaptive.enabled                                   true&lt;br /&gt;
spark.sql.adaptive.skewJoin.enabled                          true&lt;br /&gt;
spark.sql.adaptive.skewJoin.skewedPartitionFactor            5.0&lt;br /&gt;
spark.sql.adaptive.skewJoin.skewedPartitionThresholdInBytes  256MB&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Manual remedies ==&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Broadcast the small side.&amp;#039;&amp;#039;&amp;#039; A [[broadcast join]] has no shuffle on the large side, so a hot key in the large table cannot pile up in one task. Use the &amp;lt;code&amp;gt;BROADCAST&amp;lt;/code&amp;gt; [[join strategy hints|hint]] when the small side fits.&amp;lt;ref name=&amp;quot;perf&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Salting.&amp;#039;&amp;#039;&amp;#039; Add a random suffix to the hot key on one side and replicate the other side, so one key&amp;#039;s rows spread over many tasks. See [[Salting]].&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Filter or handle hot values separately.&amp;#039;&amp;#039;&amp;#039; Rows with a &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; join key never match in an inner join, so filtering them out before the join removes a common hot key.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Pre-aggregate.&amp;#039;&amp;#039;&amp;#039; Aggregating before a join reduces the rows per key that the shuffle has to move.&lt;br /&gt;
&lt;br /&gt;
== Data skew compared across engines ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! !! Apache Spark !! Apache Flink !! Trino&lt;br /&gt;
|-&lt;br /&gt;
! Automatic skewed join handling&lt;br /&gt;
| AQE skew join splits skewed sort-merge and shuffled hash join partitions at runtime; on by default&amp;lt;ref name=&amp;quot;perf&amp;quot; /&amp;gt;&lt;br /&gt;
| The Adaptive Batch Scheduler&amp;#039;s skewed join optimization splits skewed partitions in batch jobs; on by default, controlled by &amp;lt;code&amp;gt;table.optimizer.skewed-join-optimization.strategy&amp;lt;/code&amp;gt;&amp;lt;ref name=&amp;quot;flinkab&amp;quot;&amp;gt;{{Cite web |url=https://nightlies.apache.org/flink/flink-docs-stable/docs/deployment/adaptive_batch/ |title=Adaptive Batch Execution (Apache Flink 2.3) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
| No dedicated skew splitting is documented; the cost-based optimizer can choose a broadcast join instead of a partitioned join&amp;lt;ref name=&amp;quot;trinocbo&amp;quot;&amp;gt;{{Cite web |url=https://trino.io/docs/current/optimizer/cost-based-optimizations.html |title=Cost-based optimizations (Trino 484) |publisher=Trino Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Skewed aggregations&lt;br /&gt;
| Partial aggregation before the shuffle (&amp;lt;code&amp;gt;partial_sum&amp;lt;/code&amp;gt; in plans); salting by hand&lt;br /&gt;
| Local-global (two-phase) aggregation, and split distinct aggregation (&amp;lt;code&amp;gt;table.optimizer.distinct-agg.split.enabled&amp;lt;/code&amp;gt;)&amp;lt;ref name=&amp;quot;flinktuning&amp;quot;&amp;gt;{{Cite web |url=https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/table/tuning/ |title=Performance Tuning (Apache Flink 2.3 Table API and SQL) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
| Not documented as a separate feature&lt;br /&gt;
|-&lt;br /&gt;
! Skewed writes&lt;br /&gt;
| &amp;lt;code&amp;gt;REBALANCE&amp;lt;/code&amp;gt; hint with AQE splits skewed output partitions&amp;lt;ref name=&amp;quot;hints&amp;quot; /&amp;gt;&lt;br /&gt;
| Automatic balancing of data distribution in the Adaptive Batch Scheduler&amp;lt;ref name=&amp;quot;flinkab&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;redistribute-writes&amp;lt;/code&amp;gt; (default true) hashes data across nodes before writing, to limit the effect of skew&amp;lt;ref name=&amp;quot;trinogen&amp;quot;&amp;gt;{{Cite web |url=https://trino.io/docs/current/admin/properties-general.html |title=General properties (Trino 484) |publisher=Trino Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Salting]]&lt;br /&gt;
* [[Shuffle]]&lt;br /&gt;
* [[Adaptive Query Execution]]&lt;br /&gt;
* [[Join strategy hints]]&lt;br /&gt;
* [[Spill (memory)]]&lt;br /&gt;
* [[Speculative execution]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Navbox open lakehouse}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;br /&gt;
[[Category:Glossary terms]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>