[fix](Nereids) fix plan shape of query64 unstable (#26012)

don't remove the physical plan after optimizing the plan in dphyper.
This commit is contained in:
谢健
2023-10-30 19:49:28 +08:00
committed by GitHub
parent f70dfe27d0
commit f97c40d0e1
5 changed files with 215 additions and 242 deletions

View File

@ -67,7 +67,7 @@ class CostModelV1 extends PlanVisitor<Cost, PlanContext> {
// the penalty factor is no more than BROADCAST_JOIN_SKEW_PENALTY_LIMIT
static final double BROADCAST_JOIN_SKEW_RATIO = 30.0;
static final double BROADCAST_JOIN_SKEW_PENALTY_LIMIT = 2.0;
private int beNumber = 1;
private final int beNumber;
public CostModelV1() {
if (ConnectContext.get().getSessionVariable().isPlayNereidsDump()) {

View File

@ -73,8 +73,6 @@ public class Optimizer {
// Due to EnsureProjectOnTopJoin, root group can't be Join Group, so DPHyp doesn't change the root group
cascadesContext.pushJob(new JoinOrderJob(root, cascadesContext.getCurrentJobContext()));
cascadesContext.getJobScheduler().executeJobPool(cascadesContext);
// after DPHyp just keep logical expression
cascadesContext.getMemo().removePhysicalExpression();
cascadesContext.getStatementContext().setOtherJoinReorder(true);
}

View File

@ -50,7 +50,6 @@ import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -116,31 +115,6 @@ public class Memo {
return groupExpressions.size();
}
/** just keep LogicalExpression in Memo. */
public void removePhysicalExpression() {
groupExpressions.entrySet().removeIf(entry -> entry.getValue().getPlan() instanceof PhysicalPlan);
Iterator<Map.Entry<GroupId, Group>> iterator = groups.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<GroupId, Group> entry = iterator.next();
Group group = entry.getValue();
group.clearPhysicalExpressions();
group.clearLowestCostPlans();
group.removeParentPhysicalExpressions();
group.setExplored(false);
if (group.getLogicalExpressions().isEmpty() && group.getPhysicalExpressions().isEmpty()) {
iterator.remove();
}
}
// logical groupExpression reset ruleMask
groupExpressions.values().stream()
.filter(groupExpression -> groupExpression.getPlan() instanceof LogicalPlan)
.forEach(GroupExpression::clearApplied);
}
private Plan skipProject(Plan plan, Group targetGroup) {
// Some top project can't be eliminated
if (plan instanceof LogicalProject) {