[feature](nereids)set nereids cbo weights by session var #21293

good for tune cost model
This commit is contained in:
minghong
2023-06-29 18:54:04 +08:00
committed by GitHub
parent 8c532e8808
commit 419f51ca2c
2 changed files with 43 additions and 4 deletions

View File

@ -34,9 +34,6 @@ import com.google.common.base.Preconditions;
* An example is tpch q15.
*/
public class CostWeight {
static final double CPU_WEIGHT = 1;
static final double MEMORY_WEIGHT = 1;
static final double NETWORK_WEIGHT = 1.5;
static final double DELAY = 0.5;
final double cpuWeight;
@ -69,7 +66,10 @@ public class CostWeight {
}
public static CostWeight get() {
return new CostWeight(CPU_WEIGHT, MEMORY_WEIGHT, NETWORK_WEIGHT,
double cpuWeight = ConnectContext.get().getSessionVariable().getCboCpuWeight();
double memWeight = ConnectContext.get().getSessionVariable().getCboMemWeight();
double netWeight = ConnectContext.get().getSessionVariable().getCboNetWeight();
return new CostWeight(cpuWeight, memWeight, netWeight,
ConnectContext.get().getSessionVariable().getNereidsCboPenaltyFactor());
}

View File

@ -350,6 +350,12 @@ public class SessionVariable implements Serializable, Writable {
public static final String EXTERNAL_TABLE_ANALYZE_PART_NUM = "external_table_analyze_part_num";
public static final String CBO_CPU_WEIGHT = "cbo_cpu_weight";
public static final String CBO_MEM_WEIGHT = "cbo_mem_weight";
public static final String CBO_NET_WEIGHT = "cbo_net_weight";
public static final List<String> DEBUG_VARIABLES = ImmutableList.of(
SKIP_DELETE_PREDICATE,
SKIP_DELETE_BITMAP,
@ -669,6 +675,39 @@ public class SessionVariable implements Serializable, Writable {
@VariableMgr.VarAttr(name = BE_NUMBER_FOR_TEST)
private int beNumberForTest = -1;
public double getCboCpuWeight() {
return cboCpuWeight;
}
public void setCboCpuWeight(double cboCpuWeight) {
this.cboCpuWeight = cboCpuWeight;
}
public double getCboMemWeight() {
return cboMemWeight;
}
public void setCboMemWeight(double cboMemWeight) {
this.cboMemWeight = cboMemWeight;
}
public double getCboNetWeight() {
return cboNetWeight;
}
public void setCboNetWeight(double cboNetWeight) {
this.cboNetWeight = cboNetWeight;
}
@VariableMgr.VarAttr(name = CBO_CPU_WEIGHT)
private double cboCpuWeight = 1.0;
@VariableMgr.VarAttr(name = CBO_MEM_WEIGHT)
private double cboMemWeight = 1.0;
@VariableMgr.VarAttr(name = CBO_NET_WEIGHT)
private double cboNetWeight = 1.5;
@VariableMgr.VarAttr(name = DISABLE_JOIN_REORDER)
private boolean disableJoinReorder = false;