/** * Returns the importance of a child to a parent. This is defined by the * importance of the parent, pro-rated by the cost of the child. For * example, if the parent has importance = 0.8 and cost 100, then a child * with cost 50 will have importance 0.4, and a child with cost 25 will have * importance 0.2. */ private double computeImportanceOfChild( RelSubset child, RelSubset parent) { final double parentImportance = getImportance(parent); final double childCost = toDouble(planner.getCost(child)); final double parentCost = toDouble(planner.getCost(parent)); double alpha = childCost / parentCost; if (alpha >= 1.0) { // child is always less important than parent alpha = 0.99; } final double importance = parentImportance * alpha; if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest( "Importance of [" + child + "] to its parent [" + parent + "] is " + importance + " (parent importance=" + parentImportance + ", child cost=" + childCost + ", parent cost=" + parentCost + ")"); } return importance; }
/** * Returns the importance of a child to a parent. This is defined by the * importance of the parent, pro-rated by the cost of the child. For * example, if the parent has importance = 0.8 and cost 100, then a child * with cost 50 will have importance 0.4, and a child with cost 25 will have * importance 0.2. */ private double computeImportanceOfChild( RelSubset child, RelSubset parent) { final double parentImportance = getImportance(parent); final double childCost = toDouble(planner.getCost(child)); final double parentCost = toDouble(planner.getCost(parent)); double alpha = (childCost / parentCost); if (alpha >= 1.0) { // child is always less important than parent alpha = 0.99; } final double importance = parentImportance * alpha; if (tracer.isLoggable(Level.FINEST)) { tracer.finest( "Importance of [" + child + "] to its parent [" + parent + "] is " + importance + " (parent importance=" + parentImportance + ", child cost=" + childCost + ", parent cost=" + parentCost + ")"); } return importance; }
/** * Checks internal consistency. */ protected void validate() { for (RelSet set : allSets) { if (set.equivalentSet != null) { throw new AssertionError( "set [" + set + "] has been merged: it should not be in the list"); } for (RelSubset subset : set.subsets) { if (subset.set != set) { throw new AssertionError( "subset [" + subset.getDescription() + "] is in wrong set [" + set + "]"); } for (RelNode rel : subset.getRels()) { RelOptCost relCost = getCost(rel); if (relCost.isLt(subset.bestCost)) { throw new AssertionError( "rel [" + rel.getDescription() + "] has lower cost " + relCost + " than best cost " + subset.bestCost + " of subset [" + subset.getDescription() + "]"); } } } } }
/** * Checks internal consistency. */ protected void validate() { for (RelSet set : allSets) { if (set.equivalentSet != null) { throw new AssertionError( "set [" + set + "] has been merged: it should not be in the list"); } for (RelSubset subset : set.subsets) { if (subset.set != set) { throw new AssertionError( "subset [" + subset.getDescription() + "] is in wrong set [" + set + "]"); } for (RelNode rel : subset.getRels()) { RelOptCost relCost = getCost(rel); if (relCost.isLt(subset.bestCost)) { throw new AssertionError( "rel [" + rel.getDescription() + "] has lower cost " + relCost + " than best cost " + subset.bestCost + " of subset [" + subset.getDescription() + "]"); } } } } }
final RelOptCost cost = planner.getCost(rel); if (cost.isLt(bestCost)) { if (LOGGER.isLoggable(Level.FINER)) {
final RelOptCost cost = planner.getCost(rel); if (cost.isLt(bestCost)) { if (tracer.isLoggable(Level.FINER)) {
pw.println(", cumulative cost=" + getCost(rel));
", rowcount=" + RelMetadataQuery.getRowCount(rel)); pw.println(", cumulative cost=" + getCost(rel));
public RelOptCost getCost(RelNode rel) { assert rel != null : "pre-condition: rel != null"; if (rel instanceof RelSubset) { return ((RelSubset) rel).bestCost; } if (rel.getTraitSet().getTrait(0) == Convention.NONE) { return costFactory.makeInfiniteCost(); } RelOptCost cost = RelMetadataQuery.getNonCumulativeCost(rel); if (!zeroCost.isLt(cost)) { // cost must be positive, so nudge it cost = costFactory.makeTinyCost(); } for (RelNode input : rel.getInputs()) { cost = cost.plus(getCost(input)); } return cost; }
public RelOptCost getCost(RelNode rel) { assert rel != null : "pre-condition: rel != null"; if (rel instanceof RelSubset) { return ((RelSubset) rel).bestCost; } if (rel.getTraitSet().getTrait(0) == Convention.NONE) { return makeInfiniteCost(); } RelOptCost cost = RelMetadataQuery.getNonCumulativeCost(rel); if (!VolcanoCost.ZERO.isLt(cost)) { // cost must be positive, so nudge it cost = makeTinyCost(); } for (RelNode input : rel.getInputs()) { cost = cost.plus(getCost(input)); } return cost; }