Skip to content

Commit

Permalink
[feature](nereids)set nereids cbo weights by session var apache#21293
Browse files Browse the repository at this point in the history
good for tune cost model
  • Loading branch information
englefly authored Jun 29, 2023
1 parent 8c532e8 commit 419f51c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
* 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;
Expand Down Expand Up @@ -69,7 +66,10 @@ public CostWeight(double cpuWeight, double memoryWeight, double networkWeight, d
}

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());
}

Expand Down
39 changes: 39 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -669,6 +675,39 @@ public int getBeNumberForTest() {
@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;

Expand Down

0 comments on commit 419f51c

Please sign in to comment.