[feature](nereids) let user define right deep tree penalty by session variable (#14040)
it is hard for us to find a proper factor for all queries. default is 0.7
This commit is contained in:
@ -51,14 +51,7 @@ public class CostCalculator {
|
||||
static final double CPU_WEIGHT = 1;
|
||||
static final double MEMORY_WEIGHT = 1;
|
||||
static final double NETWORK_WEIGHT = 1.5;
|
||||
/**
|
||||
* Except stats information, there are some special criteria in doris.
|
||||
* For example, in hash join cluster, BE could build hash tables
|
||||
* in parallel for left deep tree. And hence, we need to punish right deep tree.
|
||||
* penalyWeight is the factor of punishment.
|
||||
* The punishment is denoted by stats.penalty.
|
||||
*/
|
||||
static final double PENALTY_WEIGHT = 0.5;
|
||||
|
||||
/**
|
||||
* The intuition behind `HEAVY_OPERATOR_PUNISH_FACTOR` is we need to avoid this form of join patterns:
|
||||
* Plan1: L join ( AGG1(A) join AGG2(B))
|
||||
@ -80,7 +73,16 @@ public class CostCalculator {
|
||||
CostEstimator costCalculator = new CostEstimator();
|
||||
CostEstimate costEstimate = groupExpression.getPlan().accept(costCalculator, planContext);
|
||||
groupExpression.setCostEstimate(costEstimate);
|
||||
CostWeight costWeight = new CostWeight(CPU_WEIGHT, MEMORY_WEIGHT, NETWORK_WEIGHT, PENALTY_WEIGHT);
|
||||
/*
|
||||
* About PENALTY:
|
||||
* Except stats information, there are some special criteria in doris.
|
||||
* For example, in hash join cluster, BE could build hash tables
|
||||
* in parallel for left deep tree. And hence, we need to punish right deep tree.
|
||||
* penalyWeight is the factor of punishment.
|
||||
* The punishment is denoted by stats.penalty.
|
||||
*/
|
||||
CostWeight costWeight = new CostWeight(CPU_WEIGHT, MEMORY_WEIGHT, NETWORK_WEIGHT,
|
||||
ConnectContext.get().getSessionVariable().getNereidsCboPenaltyFactor());
|
||||
return costWeight.calculate(costEstimate);
|
||||
}
|
||||
|
||||
|
||||
@ -191,6 +191,8 @@ public class SessionVariable implements Serializable, Writable {
|
||||
public static final String ENABLE_NEREIDS_RUNTIME_FILTER = "enable_nereids_runtime_filter";
|
||||
|
||||
public static final String NEREIDS_STAR_SCHEMA_SUPPORT = "nereids_star_schema_support";
|
||||
|
||||
public static final String NEREIDS_CBO_PENALTY_FACTOR = "nereids_cbo_penalty_factor";
|
||||
public static final String ENABLE_NEREIDS_TRACE = "enable_nereids_trace";
|
||||
public static final String ENABLE_NEREIDS_REORDER_TO_ELIMINATE_CROSS_JOIN =
|
||||
"enable_nereids_reorder_to_eliminate_cross_join";
|
||||
@ -516,6 +518,8 @@ public class SessionVariable implements Serializable, Writable {
|
||||
@VariableMgr.VarAttr(name = NEREIDS_STAR_SCHEMA_SUPPORT)
|
||||
private boolean nereidsStarSchemaSupport = true;
|
||||
|
||||
@VariableMgr.VarAttr(name = NEREIDS_CBO_PENALTY_FACTOR)
|
||||
private double nereidsCboPenaltyFactor = 0.7;
|
||||
@VariableMgr.VarAttr(name = ENABLE_NEREIDS_TRACE)
|
||||
private boolean enableNereidsTrace = false;
|
||||
|
||||
@ -1103,6 +1107,14 @@ public class SessionVariable implements Serializable, Writable {
|
||||
return isEnableNereidsPlanner() && nereidsStarSchemaSupport;
|
||||
}
|
||||
|
||||
public double getNereidsCboPenaltyFactor() {
|
||||
return nereidsCboPenaltyFactor;
|
||||
}
|
||||
|
||||
public void setNereidsCboPenaltyFactor(double penaltyFactor) {
|
||||
this.nereidsCboPenaltyFactor = penaltyFactor;
|
||||
}
|
||||
|
||||
public boolean isEnableNereidsTrace() {
|
||||
return isEnableNereidsPlanner() && enableNereidsTrace;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user