This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 48c8fc7d972 branch-3.0: [improve](planner) select * unique_table limit 
n should use one instance #53948 (#54182)
48c8fc7d972 is described below

commit 48c8fc7d9725caa632fe42bbfb2caddd188511b6
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Aug 13 09:50:34 2025 +0800

    branch-3.0: [improve](planner) select * unique_table limit n should use one 
instance #53948 (#54182)
    
    Cherry-picked from #53948
    
    Co-authored-by: zhangstar333 <[email protected]>
---
 be/src/pipeline/exec/scan_operator.cpp             |  4 +++-
 .../java/org/apache/doris/planner/ScanNode.java    | 27 ++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/be/src/pipeline/exec/scan_operator.cpp 
b/be/src/pipeline/exec/scan_operator.cpp
index 94d6b6d4db7..6ff5442f827 100644
--- a/be/src/pipeline/exec/scan_operator.cpp
+++ b/be/src/pipeline/exec/scan_operator.cpp
@@ -1213,7 +1213,9 @@ Status ScanOperatorX<LocalStateType>::init(const 
TPlanNode& tnode, RuntimeState*
         // is checked in previous branch.
         if (query_options.enable_adaptive_pipeline_task_serial_read_on_limit) {
             
DCHECK(query_options.__isset.adaptive_pipeline_task_serial_read_on_limit);
-            if (!tnode.__isset.conjuncts || tnode.conjuncts.empty()) {
+            if (!tnode.__isset.conjuncts || tnode.conjuncts.empty() ||
+                (tnode.conjuncts.size() == 1 && tnode.__isset.olap_scan_node &&
+                 tnode.olap_scan_node.keyType == TKeysType::UNIQUE_KEYS)) {
                 if (tnode.limit > 0 &&
                     tnode.limit <= 
query_options.adaptive_pipeline_task_serial_read_on_limit) {
                     _should_run_serial = true;
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 b4033a0535e..4a0a38c3adc 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
@@ -38,6 +38,7 @@ import org.apache.doris.analysis.TableSnapshot;
 import org.apache.doris.analysis.TupleDescriptor;
 import org.apache.doris.analysis.TupleId;
 import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.KeysType;
 import org.apache.doris.catalog.OlapTable;
 import org.apache.doris.catalog.PartitionInfo;
 import org.apache.doris.catalog.PrimitiveType;
@@ -757,8 +758,30 @@ public abstract class ScanNode extends PlanNode implements 
SplitGenerator {
             // No connection context, typically for broker load.
         }
 
-        // For UniqueKey table, we will use multiple instance.
-        return hasLimit() && getLimit() <= 
adaptivePipelineTaskSerialReadOnLimit && conjuncts.isEmpty();
+        if (hasLimit() && getLimit() <= adaptivePipelineTaskSerialReadOnLimit) 
{
+            if (conjuncts.isEmpty()) {
+                return true;
+            } else {
+                if (this instanceof OlapScanNode) {
+                    OlapScanNode olapScanNode = (OlapScanNode) this;
+                    if (olapScanNode.getOlapTable() != null
+                            && olapScanNode.getOlapTable().getKeysType() == 
KeysType.UNIQUE_KEYS) {
+                        // If the table is unique keys, we can check if the 
conjuncts only contains
+                        // delete sign
+                        if (conjuncts.size() == 1 && conjuncts.get(0) 
instanceof BinaryPredicate) {
+                            BinaryPredicate binaryPredicate = 
(BinaryPredicate) conjuncts.get(0);
+                            if (binaryPredicate.getOp() == 
BinaryPredicate.Operator.EQ
+                                    && binaryPredicate.getChild(0) instanceof 
SlotRef
+                                    && ((SlotRef) 
binaryPredicate.getChild(0)).getDesc().getColumn().getName()
+                                            .equals(Column.DELETE_SIGN)) {
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return false;
     }
 
     // In cloud mode, meta read lock is not enough to keep a snapshot of the 
partition versions.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to