diff --git a/docs/sql-performance-tuning.md b/docs/sql-performance-tuning.md index b443e3d9c5f59..ab69dd1bf171b 100644 --- a/docs/sql-performance-tuning.md +++ b/docs/sql-performance-tuning.md @@ -428,3 +428,100 @@ You can control the details of how AQE works by providing your own cost evaluato 3.2.0 + +## Storage Partition Join + +Storage Partition Join (SPJ) is an optimization technique in Spark SQL that makes use the existing storage layout to avoid the shuffle phase. + +This is a generalization of the concept of Bucket Joins, which is only applicable for [bucketed](sql-data-sources-load-save-functions.html#bucketing-sorting-and-partitioning) tables, to any table partitioned by function registered in FunctionCatalog. Storage Partition Joins are currently supported for compatible V2 DataSources. + +The following SQL properties enable Storage Partition Join. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Property NameDefaultMeaningSince Version
spark.sql.sources.v2.bucketing.enabledfalse + When true, try to eliminate shuffle by using the partitioning reported by a compatible V2 data source. + 3.3.0
spark.sql.sources.v2.bucketing.pushPartValues.enabledtrue + When enabled, try to eliminate shuffle if one side of the join has missing partition values from the other side. This config requires spark.sql.sources.v2.bucketing.enabled to be true. + 3.4.0
spark.sql.requireAllClusterKeysForCoPartitiontrue + When true, require the join or MERGE keys to be same and in the same order as the partition keys to eliminate shuffle. Hence, set to false in this situation to eliminate shuffle. + 3.4.0
spark.sql.sources.v2.bucketing.partiallyClusteredDistribution.enabledfalse + When true, and when the join is not a full outer join, enable skew optimizations to handle partitions with large amounts of data when avoiding shuffle. One side will be chosen as the big table based on table statistics, and the splits on this side will be partially-clustered. The splits of the other side will be grouped and replicated to match. This config requires both spark.sql.sources.v2.bucketing.enabled and spark.sql.sources.v2.bucketing.pushPartValues.enabled to be true. + 3.4.0
spark.sql.sources.v2.bucketing.allowJoinKeysSubsetOfPartitionKeys.enabledfalse + When enabled, try to avoid shuffle if join or MERGE condition does not include all partition columns. This config requires both spark.sql.sources.v2.bucketing.enabled and spark.sql.sources.v2.bucketing.pushPartValues.enabled to be true, and spark.sql.requireAllClusterKeysForCoPartition to be false. + 4.0.0
spark.sql.sources.v2.bucketing.allowCompatibleTransforms.enabledfalse + When enabled, try to avoid shuffle if partition transforms are compatible but not identical. This config requires both spark.sql.sources.v2.bucketing.enabled and spark.sql.sources.v2.bucketing.pushPartValues.enabled to be true.4.0.0
spark.sql.sources.v2.bucketing.shuffle.enabledfalse + When enabled, try to avoid shuffle on one side of the join, by recognizing the partitioning reported by a V2 data source on the other side. + 4.0.0
+ +If Storage Partition Join is performed, the query plan will not contain Exchange nodes prior to the join. + +```sql +-- Plan without Storage Partition Join + +== Physical Plan == +* Project (12) ++- * SortMergeJoin Inner (11) + :- * Sort (5) + : +- Exchange (4) // DATA SHUFFLE + : +- * Filter (3) + : +- * ColumnarToRow (2) + : +- BatchScan (1) + +- * Sort (10) + +- Exchange (9) // DATA SHUFFLE + +- * Filter (8) + +- * ColumnarToRow (7) + +- BatchScan (6) + +-- Plan with Storage Partition Join + +== Physical Plan == +* Project (10) ++- * SortMergeJoin Inner (9) + :- * Sort (4) + : +- * Filter (3) + : +- * ColumnarToRow (2) + : +- BatchScan (1) + +- * Sort (8) + +- * Filter (7) + +- * ColumnarToRow (6) + +- BatchScan (5) \ No newline at end of file