From 78502900d496a55f186bfe0c1ed2fc28ddc02a38 Mon Sep 17 00:00:00 2001 From: morningman Date: Fri, 23 Feb 2024 18:40:05 +0800 Subject: [PATCH] [fix](plan) only scan node with limit and no predicate can reduce to 1 instance --- .../main/java/org/apache/doris/planner/OlapScanNode.java | 2 ++ .../src/main/java/org/apache/doris/planner/ScanNode.java | 4 ++-- .../src/main/java/org/apache/doris/qe/Coordinator.java | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java index ce124ae2e15083..02fb26363a2d91 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java @@ -1409,6 +1409,8 @@ public boolean getShouldColoScan() { // If scan is key search, should not enable the shared scan opt to prevent the performance problem // 1. where contain the eq or in expr of key column slot // 2. key column slot is distribution column and first column + // FIXME: this is not a good check, we can not guarantee that the predicate we check can truly + // help to prune the data, so we should check the predicate's effect on the data. protected boolean isKeySearch() { List whereSlot = Lists.newArrayList(); for (Expr conjunct : conjuncts) { 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 858abeb489a3bc..be804e879727e0 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 @@ -735,7 +735,7 @@ public int getScanRangeNum() { return Integer.MAX_VALUE; } - public boolean haveLimitAndConjunts() { - return hasLimit() && !conjuncts.isEmpty(); + public boolean shouldUseOneInstance() { + return hasLimit() && conjuncts.isEmpty(); } } 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 799c687ea0fd43..5c24670fee1b77 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 @@ -2070,9 +2070,9 @@ private void computeFragmentHosts() throws Exception { if (node.isPresent() && (!node.get().shouldDisableSharedScan(context) || ignoreStorageDataDistribution)) { expectedInstanceNum = Math.max(expectedInstanceNum, 1); - // if have limit and conjunts, only need 1 instance to save cpu and + // if have limit and no conjuncts, only need 1 instance to save cpu and // mem resource - if (node.get().haveLimitAndConjunts()) { + if (node.get().shouldUseOneInstance()) { expectedInstanceNum = 1; } @@ -2083,9 +2083,9 @@ private void computeFragmentHosts() throws Exception { //the scan instance num should not larger than the tablets num expectedInstanceNum = Math.min(perNodeScanRanges.size(), parallelExecInstanceNum); } - // if have limit and conjunts, only need 1 instance to save cpu and + // if have limit and no conjuncts, only need 1 instance to save cpu and // mem resource - if (node.get().haveLimitAndConjunts()) { + if (node.get().shouldUseOneInstance()) { expectedInstanceNum = 1; }