Skip to content

Commit

Permalink
[opt](coord) use single instance only with small limit (#33888)
Browse files Browse the repository at this point in the history
  • Loading branch information
morningman authored and Doris-Extras committed Apr 19, 2024
1 parent 00adad8 commit cb5a94d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,8 @@ public int getScanRangeNum() {
return Integer.MAX_VALUE;
}

public boolean shouldUseOneInstance() {
return hasLimit() && conjuncts.isEmpty();
public boolean shouldUseOneInstance(ConnectContext ctx) {
long limitRowsForSingleInstance = ctx == null ? 10000 : ctx.getSessionVariable().limitRowsForSingleInstance;
return hasLimit() && getLimit() < limitRowsForSingleInstance && conjuncts.isEmpty();
}
}
4 changes: 2 additions & 2 deletions fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2077,7 +2077,7 @@ private void computeFragmentHosts() throws Exception {
expectedInstanceNum = Math.max(expectedInstanceNum, 1);
// if have limit and no conjuncts, only need 1 instance to save cpu and
// mem resource
if (node.get().shouldUseOneInstance()) {
if (node.get().shouldUseOneInstance(context)) {
expectedInstanceNum = 1;
}

Expand All @@ -2090,7 +2090,7 @@ private void computeFragmentHosts() throws Exception {
}
// if have limit and no conjuncts, only need 1 instance to save cpu and
// mem resource
if (node.get().shouldUseOneInstance()) {
if (node.get().shouldUseOneInstance(context)) {
expectedInstanceNum = 1;
}

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

public static final String ENABLE_STATS = "enable_stats";

public static final String LIMIT_ROWS_FOR_SINGLE_INSTANCE = "limit_rows_for_single_instance";

// CLOUD_VARIABLES_BEGIN
public static final String CLOUD_CLUSTER = "cloud_cluster";
public static final String DISABLE_EMPTY_PARTITION_PRUNE = "disable_empty_partition_prune";
Expand Down Expand Up @@ -1074,7 +1076,6 @@ public void setMaxJoinNumberOfReorder(int maxJoinNumberOfReorder) {
this.maxJoinNumberOfReorder = maxJoinNumberOfReorder;
}


@VariableMgr.VarAttr(name = MAX_JOIN_NUMBER_BUSHY_TREE)
private int maxJoinNumBushyTree = 8;

Expand Down Expand Up @@ -1117,6 +1118,14 @@ public void setMaxJoinNumberOfReorder(int maxJoinNumberOfReorder) {
@VariableMgr.VarAttr(name = NTH_OPTIMIZED_PLAN)
private int nthOptimizedPlan = 1;

@VariableMgr.VarAttr(name = LIMIT_ROWS_FOR_SINGLE_INSTANCE,
description = {"当一个 ScanNode 上没有过滤条件,且 limit 值小于这个阈值时,"
+ "系统会将这个算子的并发度调整为1,以减少简单查询的扇出",
"When a ScanNode has no filter conditions and the limit value is less than this threshold, "
+ "the system will adjust the concurrency of this operator to 1 "
+ "to reduce the fan-out of simple queries"})
public long limitRowsForSingleInstance = 10000;

public boolean isEnableLeftZigZag() {
return enableLeftZigZag;
}
Expand Down

0 comments on commit cb5a94d

Please sign in to comment.