This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b840c66a3c6 [opt](coord) use single instance only with small limit
(#33888)
b840c66a3c6 is described below
commit b840c66a3c680b5f832612bdf669b22043660b6c
Author: Mingyu Chen <[email protected]>
AuthorDate: Sat Apr 20 00:44:24 2024 +0800
[opt](coord) use single instance only with small limit (#33888)
---
.../src/main/java/org/apache/doris/planner/ScanNode.java | 5 +++--
fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java | 4 ++--
.../src/main/java/org/apache/doris/qe/SessionVariable.java | 11 ++++++++++-
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java
index a0b5d5911cf..3e25bd6e7f8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java
@@ -746,8 +746,9 @@ public abstract class ScanNode extends PlanNode {
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();
}
// In cloud mode, meta read lock is not enough to keep a snapshot of the
partition versions.
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
index 73979aefc3e..83f072a6bf1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
@@ -2082,7 +2082,7 @@ public class Coordinator implements CoordInterface {
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;
}
@@ -2095,7 +2095,7 @@ public class Coordinator implements CoordInterface {
}
// 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;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index 930fd0ad84a..5b0512683aa 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -554,6 +554,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";
@@ -1081,7 +1083,6 @@ public class SessionVariable implements Serializable,
Writable {
this.maxJoinNumberOfReorder = maxJoinNumberOfReorder;
}
-
@VariableMgr.VarAttr(name = MAX_JOIN_NUMBER_BUSHY_TREE)
private int maxJoinNumBushyTree = 8;
@@ -1124,6 +1125,14 @@ public class SessionVariable implements Serializable,
Writable {
@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;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]