Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,15 @@ public Cost visitPhysicalHashJoin(
);
}

double probeShortcutFactor = 1.0;
if (ConnectContext.get() != null && ConnectContext.get().getStatementContext() != null
&& !ConnectContext.get().getStatementContext().isHasUnknownColStats()
&& physicalHashJoin.getJoinType().isLeftSemiOrAntiJoin()
&& physicalHashJoin.getOtherJoinConjuncts().isEmpty()
&& physicalHashJoin.getMarkJoinConjuncts().isEmpty()) {
// left semi/anti has short-cut opt, add probe side factor for distinguishing from the right ones
probeShortcutFactor = context.getSessionVariable().getLeftSemiOrAntiProbeFactor();
}
if (context.isBroadcastJoin()) {
// compared with shuffle join, bc join will be taken a penalty for both build and probe side;
// currently we use the following factor as the penalty factor:
Expand All @@ -417,14 +426,15 @@ public Cost visitPhysicalHashJoin(
}
}
return CostV1.of(context.getSessionVariable(),
leftRowCount + rightRowCount * buildSideFactor + outputRowCount * probeSideFactor,
leftRowCount * probeShortcutFactor + rightRowCount * probeShortcutFactor * buildSideFactor
+ outputRowCount * probeSideFactor,
rightRowCount,
0
);
}
return CostV1.of(context.getSessionVariable(), leftRowCount + rightRowCount + outputRowCount,
rightRowCount,
0
return CostV1.of(context.getSessionVariable(),
leftRowCount * probeShortcutFactor + rightRowCount * probeShortcutFactor + outputRowCount,
rightRowCount, 0
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ public class SessionVariable implements Serializable, Writable {

public static final String FORBID_UNKNOWN_COLUMN_STATS = "forbid_unknown_col_stats";
public static final String BROADCAST_RIGHT_TABLE_SCALE_FACTOR = "broadcast_right_table_scale_factor";
public static final String LEFT_SEMI_OR_ANTI_PROBE_FACTOR = "left_semi_or_anti_probe_factor";
public static final String BROADCAST_ROW_COUNT_LIMIT = "broadcast_row_count_limit";

// percentage of EXEC_MEM_LIMIT
Expand Down Expand Up @@ -1239,6 +1240,9 @@ public void setEnableLeftZigZag(boolean enableLeftZigZag) {
@VariableMgr.VarAttr(name = BROADCAST_RIGHT_TABLE_SCALE_FACTOR)
private double broadcastRightTableScaleFactor = 0.0;

@VariableMgr.VarAttr(name = LEFT_SEMI_OR_ANTI_PROBE_FACTOR)
private double leftSemiOrAntiProbeFactor = 0.05;

@VariableMgr.VarAttr(name = BROADCAST_ROW_COUNT_LIMIT, needForward = true)
private double broadcastRowCountLimit = 30000000;

Expand Down Expand Up @@ -2642,6 +2646,14 @@ public void setBroadcastRightTableScaleFactor(double broadcastRightTableScaleFac
this.broadcastRightTableScaleFactor = broadcastRightTableScaleFactor;
}

public double getLeftSemiOrAntiProbeFactor() {
return leftSemiOrAntiProbeFactor;
}

public void setLeftSemiOrAntiProbeFactor(double leftSemiOrAntiProbeFactor) {
this.leftSemiOrAntiProbeFactor = leftSemiOrAntiProbeFactor;
}

public double getBroadcastRowCountLimit() {
return broadcastRowCountLimit;
}
Expand Down