-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Choose broadcast join when one side is small the other side is unknown #19978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ | |
| import static com.facebook.presto.SystemSessionProperties.getJoinDistributionType; | ||
| import static com.facebook.presto.SystemSessionProperties.getJoinMaxBroadcastTableSize; | ||
| import static com.facebook.presto.SystemSessionProperties.isSizeBasedJoinDistributionTypeEnabled; | ||
| import static com.facebook.presto.SystemSessionProperties.isUseBroadcastJoinWhenBuildSizeSmallProbeSizeUnknownEnabled; | ||
| import static com.facebook.presto.cost.CostCalculatorWithEstimatedExchanges.calculateJoinCostWithoutOutput; | ||
| import static com.facebook.presto.sql.analyzer.FeaturesConfig.JoinDistributionType.AUTOMATIC; | ||
| import static com.facebook.presto.sql.planner.iterative.rule.JoinSwappingUtils.isBelowBroadcastLimit; | ||
|
|
@@ -49,6 +50,8 @@ | |
| import static com.facebook.presto.sql.planner.plan.JoinNode.DistributionType.PARTITIONED; | ||
| import static com.facebook.presto.sql.planner.plan.JoinNode.DistributionType.REPLICATED; | ||
| import static com.facebook.presto.sql.planner.plan.Patterns.join; | ||
| import static com.google.common.collect.ImmutableList.toImmutableList; | ||
| import static com.google.common.collect.Iterables.getOnlyElement; | ||
| import static java.lang.Double.NaN; | ||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
|
|
@@ -102,6 +105,10 @@ private PlanNode getCostBasedJoin(JoinNode joinNode, Context context) | |
| addJoinsWithDifferentDistributions(joinNode.flipChildren(), possibleJoinNodes, context); | ||
|
|
||
| if (possibleJoinNodes.stream().anyMatch(result -> result.getCost().hasUnknownComponents()) || possibleJoinNodes.isEmpty()) { | ||
| // TODO: currently this session parameter is added so as to roll out the plan change gradually, after proved to be a better choice, make it default and get rid of the session parameter here. | ||
| if (isUseBroadcastJoinWhenBuildSizeSmallProbeSizeUnknownEnabled(context.getSession()) && possibleJoinNodes.stream().anyMatch(result -> ((JoinNode) result.getPlanNode()).getDistributionType().get().equals(REPLICATED))) { | ||
| return getOnlyElement(possibleJoinNodes.stream().filter(result -> ((JoinNode) result.getPlanNode()).getDistributionType().get().equals(REPLICATED)).map(x -> x.getPlanNode()).collect(toImmutableList())); | ||
| } | ||
| if (isSizeBasedJoinDistributionTypeEnabled(context.getSession())) { | ||
|
||
| return getSizeBasedJoin(joinNode, context); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking of default to false, and roll out gradually.