Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Nov 24, 2023
1 parent 7829873 commit 5a723e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public Cost visitPhysicalDistribute(
return CostV1.of(context.getSessionVariable(),
0,
0,
intputRowCount * childStatistics.dataSizeFactor());
intputRowCount * childStatistics.dataSizeFactor() / beNumber);
}

// replicate
Expand All @@ -205,7 +205,7 @@ public Cost visitPhysicalDistribute(
return CostV1.of(context.getSessionVariable(),
0,
0,
intputRowCount * childStatistics.dataSizeFactor() * beNumber);
intputRowCount * childStatistics.dataSizeFactor());

}

Expand All @@ -214,15 +214,15 @@ public Cost visitPhysicalDistribute(
return CostV1.of(context.getSessionVariable(),
0,
0,
intputRowCount * childStatistics.dataSizeFactor());
intputRowCount * childStatistics.dataSizeFactor() / beNumber);
}

// any
// cost of random shuffle is lower than hash shuffle.
return CostV1.of(context.getSessionVariable(),
0,
0,
intputRowCount * childStatistics.dataSizeFactor() * RANDOM_SHUFFLE_TO_HASH_SHUFFLE_FACTOR);
intputRowCount * childStatistics.dataSizeFactor() * RANDOM_SHUFFLE_TO_HASH_SHUFFLE_FACTOR / beNumber);
}

@Override
Expand Down Expand Up @@ -291,10 +291,13 @@ public Cost visitPhysicalHashJoin(
int totalInstanceNumber = parallelInstance * beNumber;
if (buildSideFactor <= 1.0) {
// use totalInstanceNumber to the power of 2 as the default factor value
buildSideFactor = Math.pow(totalInstanceNumber, 0.5);
if (buildStats.computeSize() > 1024 * 1024) {
buildSideFactor = Math.pow(totalInstanceNumber, 0.5);
}
}
probeSideFactor = broadCastJoinBalancePenalty(probeStats, buildStats);
return CostV1.of(context.getSessionVariable(),
leftRowCount + rightRowCount * buildSideFactor + outputRowCount * probeSideFactor,
leftRowCount * probeSideFactor + rightRowCount * buildSideFactor + outputRowCount,
rightRowCount,
0
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public class SessionVariable implements Serializable, Writable {
public static final String SHUFFLE_FACTOR_LOWER_BOUND = "shuffle_factor_lower_bound";

@VariableMgr.VarAttr(name = SHUFFLE_FACTOR_LOWER_BOUND)
public double shuffleFactorLowerBound = 0.01;
public double shuffleFactorLowerBound = 0.05;

public static final String ENABLE_STATS = "enable_stats";
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,11 @@ public double computeSize() {
}

public double dataSizeFactor() {
double lowerBound = 0.01;
double lowerBound = 0.05;
if (ConnectContext.get() != null) {
lowerBound = ConnectContext.get().getSessionVariable().shuffleFactorLowerBound;
}
return computeTupleSize() * lowerBound;//0.001
// return Math.max(computeTupleSize() / K_BYTES, lowerBound);
return Math.min(Math.max(computeTupleSize() / K_BYTES, lowerBound), 0.1);
}

@Override
Expand Down

0 comments on commit 5a723e9

Please sign in to comment.