-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unnecessary remote exchange from scalar correlated subquery plan
Eliminate exchanges between LeftJoin and MarkDistinctNode when planning scalar correlated subqueries. Here is a sample query. SELECT name, (SELECT name FROM region WHERE regionkey = nation.regionkey) FROM nation The plan before the change included remote and local exchanges between LeftJoin and MarkDistinctNode. - FilterProject - MarkDistinct[distinct=unique:bigint marker=is_distinct] - LocalExchange[HASH][$hashvalue] ("unique") - RemoteExchange[REPARTITION][$hashvalue_15] - LeftJoin[("regionkey" = "regionkey_0")] - AssignUniqueId - (build) After this change the plan no longer includes the exchanges. - FilterProject - MarkDistinct[distinct=unique:bigint marker=is_distinct] - LeftJoin[("regionkey" = "regionkey_0")] - AssignUniqueId - (build) The change contains two parts: - update TransformCorrelatedScalarSubquery to include all probe symbols in MarkDistinctNode#distinctSymbols; - add logic to AddLocalExchanges rule to drop everything but `unique` symbol from MarkDistinctNode#distinctSymbols. First change allows AddExchanges rule to see that partitioning required by MarkDistinctNode is already satified: partitioned_on(join_key) implies partitioned_on(all_probe_rows). Second change avoids increasing the cost of MarkDistinctNode.
- Loading branch information
1 parent
2c6ba08
commit 575a9a6
Showing
4 changed files
with
105 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters