Skip to content

Commit 57dadf5

Browse files
committed
optimize er left join global (#2334)
* optimize er left join global * optimize er left join global * fix checkstyle (cherry picked from commit 2f6b3bf)
1 parent 54eb8d7 commit 57dadf5

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

dble_checkstyle_suppression.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"http://checkstyle.sourceforge.net/dtds/suppressions_1_1.dtd">
1111

1212
<suppressions>
13-
<suppress checks=".*" files="StructureMeta.java"/>
1413
<suppress checks=".*" files="UcoreInterface.java"/>
1514
<suppress checks=".*" files="UcoreGrpc.java"/>
1615
<suppress checks=".*" files="AlertBlockQueue.java"/>
@@ -24,6 +23,7 @@
2423
<suppress checks=".*" files="BTraceCostTime.java"/>
2524
<suppress checks="CyclomaticComplexity" files="CreateTableParserImp.java"/>
2625
<suppress checks="CyclomaticComplexity" files="XMLSchemaLoader.java"/>
26+
<suppress checks="CyclomaticComplexity" files="GlobalTableProcessor.java"/>
2727
<suppress checks="UncommentedMain" files="XmltoCluster.java"/>
2828
<suppress checks="UncommentedMain" files="XmltoZkMain.java"/>
2929
</suppressions>

src/main/java/com/actiontech/dble/plan/optimizer/ERJoinChooser.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public JoinNode optimize() {
7777
* left join's ER is different from inner join's
7878
* ex:t1,t2 ,if t1 left join t2 on
7979
* t1.id=t2.id can be pushed
80-
* < we cna't change left join's structure>
80+
* < we can't change left join's structure>
8181
*
8282
* @return
8383
*/
@@ -107,6 +107,7 @@ private ERTable getLeftOutJoinChildER(JoinNode joinNode, PlanNode child, Item on
107107
return null;
108108
else if (!PlanUtil.isERNode(child) && child.type() != PlanNode.PlanNodeType.TABLE)
109109
return null;
110+
110111
if (onItem == null || !onItem.type().equals(Item.ItemType.FIELD_ITEM))
111112
return null;
112113
Pair<TableNode, ItemField> joinColumnInfo = PlanUtil.findColumnInTableLeaf((ItemField) onItem, joinNode);
@@ -130,7 +131,7 @@ else if (!PlanUtil.isERNode(child) && child.type() != PlanNode.PlanNodeType.TABL
130131
/* ------------------- left join optimizer end -------------------- */
131132

132133
/**
133-
* inner join's ER, rebuild inner joi's unit
134+
* inner join's ER, rebuild inner join's unit
134135
*
135136
* @return
136137
*/
@@ -390,7 +391,8 @@ private void initInnerJoinUnits(JoinNode node) {
390391
private boolean isUnit(PlanNode node) {
391392
if (isGlobalTree(node))
392393
return true;
393-
else return node.type() != PlanNode.PlanNodeType.JOIN || node.isWithSubQuery() || !((JoinNode) node).isInnerJoin();
394+
else
395+
return node.type() != PlanNode.PlanNodeType.JOIN || node.isWithSubQuery() || !((JoinNode) node).isInnerJoin();
394396
}
395397

396398
/**

src/main/java/com/actiontech/dble/plan/optimizer/GlobalTableProcessor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ private static boolean initGlobalStatus(PlanNode tn) {
5555
if (PlanUtil.isERNode(tn)) {
5656
// treat er join as an un global table
5757
tn.setUnGlobalTableCount(1);
58-
Set<String> newSet = new HashSet<>();
59-
newSet.addAll(tn.getReferedTableNodes().get(0).getNoshardNode());
58+
Set<String> newSet = new HashSet<>(tn.getReferedTableNodes().get(0).getNoshardNode());
6059
tn.setNoshardNode(newSet);
6160
} else {
6261
int unGlobalCount = calcUnGlobalCount(tn);
@@ -84,7 +83,9 @@ private static boolean initGlobalStatus(PlanNode tn) {
8483
if (left.getUnGlobalTableCount() == 0) { // left node is global,left join will not push down
8584
tn.setNoshardNode(null);
8685
status = false;
87-
} else if (left.type() == PlanNode.PlanNodeType.TABLE || PlanUtil.isERNode(left)) {
86+
} else if (left.type() == PlanNode.PlanNodeType.TABLE ||
87+
PlanUtil.isERNode(left) ||
88+
left.getNoshardNode() != null && left.getNoshardNode().size() > 0) {
8889
if (!isGlobalTableBigEnough(jn)) {
8990
tn.setNoshardNode(null);
9091
status = false;

0 commit comments

Comments
 (0)