Code review comment: This is because too many tables will cause a lot of optimzer time? this can be configurable to avoid some bad cases?

Code before review:
void memoOptimize(ConnectContext connectContext, Memo memo, TaskContext rootTaskContext) {
OptExpression tree = memo.getRootGroup().extractLogicalTree();
SessionVariable sessionVariable = connectContext.getSessionVariable();
if (Utils.countJoinNodeSize(tree, CboTablePruneRule.JOIN_TYPES) < 10 &&
sessionVariable.isEnableCboTablePrune()) {
context.getRuleSet().addCboTablePruneRule();
}
int innerCrossJoinNode = Utils.countJoinNodeSize(tree, JoinOperator.innerCrossJoinSet());
if (!sessionVariable.isDisableJoinReorder() && innerCrossJoinNode < sessionVariable.getCboMaxReorderNode()) {
if (innerCrossJoinNode > sessionVariable.getCboMaxReorderNodeUseExhaustive()) {
CTEUtils.collectForceCteStatistics(memo, context);
OptimizerTraceUtil.logOptExpression(connectContext, "before ReorderJoinRule:\n%s", tree);
new ReorderJoinRule().transform(tree, context);
OptimizerTraceUtil.logOptExpression(connectContext, "after ReorderJoinRule:\n%s", tree);
context.getRuleSet().addJoinCommutativityWithOutInnerRule();
} else {
if (Utils.countJoinNodeSize(tree, JoinOperator.semiAntiJoinSet()) <
sessionVariable.getCboMaxReorderNodeUseExhaustive()) {
context.getRuleSet().getTransformRules().add(new SemiReorderRule());
}
context.getRuleSet().addJoinTransformationRules();
}
}
if (!sessionVariable.isDisableJoinReorder() && sessionVariable.isEnableOuterJoinReorder()
&& Utils.capableOuterReorder(tree, sessionVariable.getCboReorderThresholdUseExhaustive())) {
context.getRuleSet().addOuterJoinTransformationRules();
}
if (!sessionVariable.isMVPlanner()) {
String joinImplementationMode = ConnectContext.get().getSessionVariable().getJoinImplementationMode();
if ("merge".equalsIgnoreCase(joinImplementationMode)) {
context.getRuleSet().addMergeJoinImplementationRule();
} else if ("hash".equalsIgnoreCase(joinImplementationMode)) {
context.getRuleSet().addHashJoinImplementationRule();
} else if ("nestloop".equalsIgnoreCase(joinImplementationMode)) {
context.getRuleSet().addNestLoopJoinImplementationRule();
} else {
context.getRuleSet().addAutoJoinImplementationRule();
}
} else {
context.getRuleSet().addRealtimeMVRules();
}
if (isEnableMultiTableRewrite(connectContext, tree)) {
if (sessionVariable.isEnableMaterializedViewViewDeltaRewrite() &&
rootTaskContext.getOptimizerContext().getCandidateMvs()
.stream().anyMatch(MaterializationContext::hasMultiTables)) {
context.getRuleSet().addSingleTableMvRewriteRule();
}
context.getRuleSet().addMultiTableMvRewriteRule();
}
context.getTaskScheduler().pushTask(new OptimizeGroupTask(rootTaskContext, memo.getRootGroup()));
context.getTaskScheduler().executeTasks(rootTaskContext);
}

Line under review: if (Utils.countJoinNodeSize(tree, CboTablePruneRule.JOIN_TYPES) < 10 &&

Code after addressing the review:
void memoOptimize(ConnectContext connectContext, Memo memo, TaskContext rootTaskContext) {
OptExpression tree = memo.getRootGroup().extractLogicalTree();
SessionVariable sessionVariable = connectContext.getSessionVariable();
if (Utils.countJoinNodeSize(tree, CboTablePruneRule.JOIN_TYPES) < 10 &&
sessionVariable.isEnableCboTablePrune()) {
context.getRuleSet().addCboTablePruneRule();
}
int innerCrossJoinNode = Utils.countJoinNodeSize(tree, JoinOperator.innerCrossJoinSet());
if (!sessionVariable.isDisableJoinReorder() && innerCrossJoinNode < sessionVariable.getCboMaxReorderNode()) {
if (innerCrossJoinNode > sessionVariable.getCboMaxReorderNodeUseExhaustive()) {
CTEUtils.collectForceCteStatistics(memo, context);
OptimizerTraceUtil.logOptExpression(connectContext, "before ReorderJoinRule:\n%s", tree);
new ReorderJoinRule().transform(tree, context);
OptimizerTraceUtil.logOptExpression(connectContext, "after ReorderJoinRule:\n%s", tree);
context.getRuleSet().addJoinCommutativityWithOutInnerRule();
} else {
if (Utils.countJoinNodeSize(tree, JoinOperator.semiAntiJoinSet()) <
sessionVariable.getCboMaxReorderNodeUseExhaustive()) {
context.getRuleSet().getTransformRules().add(new SemiReorderRule());
}
context.getRuleSet().addJoinTransformationRules();
}
}
if (!sessionVariable.isDisableJoinReorder() && sessionVariable.isEnableOuterJoinReorder()
&& Utils.capableOuterReorder(tree, sessionVariable.getCboReorderThresholdUseExhaustive())) {
context.getRuleSet().addOuterJoinTransformationRules();
}
if (!sessionVariable.isMVPlanner()) {
String joinImplementationMode = ConnectContext.get().getSessionVariable().getJoinImplementationMode();
if ("merge".equalsIgnoreCase(joinImplementationMode)) {
context.getRuleSet().addMergeJoinImplementationRule();
} else if ("hash".equalsIgnoreCase(joinImplementationMode)) {
context.getRuleSet().addHashJoinImplementationRule();
} else if ("nestloop".equalsIgnoreCase(joinImplementationMode)) {
context.getRuleSet().addNestLoopJoinImplementationRule();
} else {
context.getRuleSet().addAutoJoinImplementationRule();
}
} else {
context.getRuleSet().addRealtimeMVRules();
}
if (isEnableMultiTableRewrite(connectContext, tree)) {
if (sessionVariable.isEnableMaterializedViewViewDeltaRewrite() &&
rootTaskContext.getOptimizerContext().getCandidateMvs()
.stream().anyMatch(MaterializationContext::hasMultiTables)) {
context.getRuleSet().addSingleTableMvRewriteRule();
}
context.getRuleSet().addMultiTableMvRewriteRule();
}
context.getTaskScheduler().pushTask(new OptimizeGroupTask(rootTaskContext, memo.getRootGroup()));
context.getTaskScheduler().executeTasks(rootTaskContext);
}