You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by en...@apache.org on 2025/11/21 06:45:02 UTC

(doris) branch tpc_preview updated: disable pk/fk optimization (#58222)

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

englefly pushed a commit to branch tpc_preview
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/tpc_preview by this push:
     new f14d5a9bf85 disable pk/fk optimization (#58222)
f14d5a9bf85 is described below

commit f14d5a9bf85c1d1ad1330ad37ce0c349d4763c9d
Author: minghong <zh...@selectdb.com>
AuthorDate: Fri Nov 21 14:44:55 2025 +0800

    disable pk/fk optimization (#58222)
    
    ### What problem does this PR solve?
    
    Issue Number: close #xxx
    
    Related PR: #xxx
    
    Problem Summary:
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [ ] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [ ] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 .../org/apache/doris/nereids/rules/rewrite/EliminateJoinByFK.java     | 4 ++++
 .../doris/nereids/rules/rewrite/PushDownAggThroughJoinOnPkFk.java     | 4 ++++
 fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java     | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByFK.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByFK.java
index b8e2ab6a003..9fb76643e5a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByFK.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByFK.java
@@ -33,6 +33,7 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
 import org.apache.doris.nereids.util.ImmutableEqualSet;
 import org.apache.doris.nereids.util.JoinUtils;
+import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableList;
@@ -61,6 +62,9 @@ public class EliminateJoinByFK extends OneRewriteRuleFactory {
         return logicalProject(
                 logicalJoin().when(join -> join.getJoinType().isInnerJoin())
         ).then(project -> {
+            if (ConnectContext.get() != null && !ConnectContext.get().getSessionVariable().enablePkFkOptimization) {
+                return null;
+            }
             LogicalJoin<Plan, Plan> join = project.child();
             ImmutableEqualSet<Slot> equalSet = join.getEqualSlots();
             Set<Slot> residualSlot = Sets.difference(project.getInputSlots(), equalSet.getAllItemSet());
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushDownAggThroughJoinOnPkFk.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushDownAggThroughJoinOnPkFk.java
index 2aeb59ae9c7..8a04048f6d9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushDownAggThroughJoinOnPkFk.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushDownAggThroughJoinOnPkFk.java
@@ -33,6 +33,7 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
 import org.apache.doris.nereids.util.JoinUtils;
+import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
@@ -87,6 +88,9 @@ public class PushDownAggThroughJoinOnPkFk implements RewriteRuleFactory {
     }
 
     private @Nullable Plan pushAgg(LogicalAggregate<?> agg, LogicalJoin<?, ?> join) {
+        if (ConnectContext.get() != null && !ConnectContext.get().getSessionVariable().enablePkFkOptimization) {
+            return null;
+        }
         InnerJoinCluster innerJoinCluster = new InnerJoinCluster();
         innerJoinCluster.collectContiguousInnerJoins(join);
         if (!innerJoinCluster.isValid()) {
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 6582abb79e5..455df78f176 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
@@ -1213,6 +1213,10 @@ public class SessionVariable implements Serializable, Writable {
     @VariableMgr.VarAttr(name = CLOUD_ENABLE_MULTI_CLUSTER_SYNC_LOAD, needForward = true)
     public static boolean cloudEnableMultiClusterSyncLoad = false;
 
+    public static final String ENABLE_PKFK_OPTIMIZATION = "enable_pkfk_optimization";
+    @VariableMgr.VarAttr(name = ENABLE_PKFK_OPTIMIZATION, needForward = true, fuzzy = false)
+    public boolean enablePkFkOptimization = false;
+
     /*
      * the parallel exec instance num for one Fragment in one BE
      * 1 means disable this feature


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org