Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-3753] Remove rule queue importance #1840

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,11 @@ public JdbcSort(
offset, fetch);
}

@Override public RelOptCost computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq) {
return super.computeSelfCost(planner, mq).multiplyBy(0.9);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need a 0.9 factor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it cheaper than default sort. Same applies on GeodeSort.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is weird to tweak the cost to select a specific Convention and why should the JDBC convention should be cheaper ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't think the following plans should have different cost, I am happy to change it back:
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey, thanks for the explanation.

}

public JdbcImplementor.Result implement(JdbcImplementor implementor) {
return implementor.implement(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public abstract class AbstractRelOptPlanner implements RelOptPlanner {

private Pattern ruleDescExclusionFilter;

private final AtomicBoolean cancelFlag;
protected final AtomicBoolean cancelFlag;

private final Set<Class<? extends RelNode>> classes = new HashSet<>();

Expand Down
26 changes: 26 additions & 0 deletions core/src/main/java/org/apache/calcite/plan/SubstitutionRule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.calcite.plan;

/**
* A rule that implements this interface indicates that the new RelNode
* is definitely better than the old one, which will be pruned by setting
* importance to 0.
*/
public interface SubstitutionRule {

}
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ void mergeWith(

// merge subsets
for (RelSubset otherSubset : otherSet.subsets) {
planner.ruleQueue.subsetImportances.remove(otherSubset);
RelSubset subset =
getOrCreateSubset(
otherSubset.getCluster(),
Expand Down Expand Up @@ -421,7 +420,7 @@ void mergeWith(
// once to fire again.)
for (RelNode rel : rels) {
assert planner.getSet(rel) == this;
planner.fireRules(rel, true);
planner.fireRules(rel);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ void propagateCostImprovements0(VolcanoPlanner planner, RelMetadataQuery mq,
// since best was changed, cached metadata for this subset should be removed
mq.clearCache(this);

// Recompute subset's importance and propagate cost change to parents
planner.ruleQueue.recompute(this);
// Propagate cost change to parents
for (RelNode parent : getParents()) {
// removes parent cached metadata since its input was changed
mq.clearCache(parent);
Expand All @@ -386,18 +385,6 @@ void propagateCostImprovements0(VolcanoPlanner planner, RelMetadataQuery mq,
}
}

public void propagateBoostRemoval(VolcanoPlanner planner) {
planner.ruleQueue.recompute(this);

if (boosted) {
boosted = false;

for (RelSubset parentSubset : getParentSubsets(planner)) {
parentSubset.propagateBoostRemoval(planner);
}
}
}

@Override public void collectVariablesUsed(Set<CorrelationId> variableSet) {
variableSet.addAll(set.variablesUsed);
}
Expand Down
Loading