Examples of PlanCostEstimator


Examples of com.foundationdb.sql.optimizer.rule.cost.PlanCostEstimator

    public CostEstimate estimateCost(IndexScan index) {
        return estimateCost(index, queryGoal.getLimit());
    }

    public CostEstimate estimateCost(IndexScan index, long limit) {
        PlanCostEstimator estimator = newEstimator();
        Set<TableSource> requiredTables = index.getRequiredTables();

        estimator.indexScan(index);

        if (!index.isCovering()) {
            estimator.flatten(tables,
                              index.getLeafMostTable(), requiredTables);
        }

        Collection<ConditionExpression> unhandledConditions =
            new HashSet<>(requiredConditions);
        if (index.getConditions() != null)
            unhandledConditions.removeAll(index.getConditions());
        if (!unhandledConditions.isEmpty()) {
            estimator.select(unhandledConditions,
                             selectivityConditions(unhandledConditions, requiredTables));
        }

        if (queryGoal.needSort(index.getOrderEffectiveness())) {
            estimator.sort(queryGoal.sortFields());
        }

        estimator.setLimit(limit);

        return estimator.getCostEstimate();
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.rule.cost.PlanCostEstimator

        if (limit < 0)
            return index.getScanCostEstimate();
        // There is a limit and this index looks to be sorted, so adjust for that
        // limit. Otherwise, the scan only cost, which includes all rows, will appear
        // too large compared to a limit-aware best plan.
        PlanCostEstimator estimator = newEstimator();
        estimator.indexScan(index);
        estimator.setLimit(limit);
        return estimator.getCostEstimate();
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.rule.cost.PlanCostEstimator

        estimator.setLimit(limit);
        return estimator.getCostEstimate();
    }

    public CostEstimate estimateCost(GroupScan scan) {
        PlanCostEstimator estimator = newEstimator();
        Set<TableSource> requiredTables = requiredColumns.getTables();

        estimator.groupScan(scan, tables, requiredTables);

        if (!requiredConditions.isEmpty()) {
            estimator.select(requiredConditions,
                             selectivityConditions(requiredConditions, requiredTables));
        }
       
        estimator.setLimit(queryGoal.getLimit());

        return estimator.getCostEstimate();
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.rule.cost.PlanCostEstimator

        return estimator.getCostEstimate();
    }

    public CostEstimate estimateCost(GroupLoopScan scan) {
        PlanCostEstimator estimator = newEstimator();
        Set<TableSource> requiredTables = scan.getRequiredTables();

        estimator.groupLoop(scan, tables, requiredTables);

        Collection<ConditionExpression> unhandledConditions =
            new HashSet<>(requiredConditions);
        addInnerJoinConditions(unhandledConditions, scan.getInsideTable());
        unhandledConditions.removeAll(scan.getJoinConditions());
        if (!unhandledConditions.isEmpty()) {
            estimator.select(unhandledConditions,
                             selectivityConditions(unhandledConditions, requiredTables));
        }

        if (queryGoal.needSort(IndexScan.OrderEffectiveness.NONE)) {
            estimator.sort(queryGoal.sortFields());
        }

        estimator.setLimit(queryGoal.getLimit());

        return estimator.getCostEstimate();
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.rule.cost.PlanCostEstimator

            output = output.getOutput();
        }
    }

    public CostEstimate estimateCost(ExpressionsHKeyScan scan) {
        PlanCostEstimator estimator = newEstimator();
        Set<TableSource> requiredTables = scan.getRequiredTables();

        estimator.hKeyRow(scan);
        estimator.flatten(tables, scan.getTable(), requiredTables);

        Collection<ConditionExpression> unhandledConditions =
            new HashSet<>(requiredConditions);
        unhandledConditions.removeAll(scan.getConditions());
        if (!unhandledConditions.isEmpty()) {
            estimator.select(unhandledConditions,
                             selectivityConditions(unhandledConditions, requiredTables));
        }

        if (queryGoal.needSort(IndexScan.OrderEffectiveness.NONE)) {
            estimator.sort(queryGoal.sortFields());
        }

        estimator.setLimit(queryGoal.getLimit());

        return estimator.getCostEstimate();
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.rule.cost.PlanCostEstimator

            op = ((CastExpression)op).getOperand();
        return col.equals(op);
    }

    public CostEstimate estimateCostSpatial(SingleIndexScan index) {
        PlanCostEstimator estimator = newEstimator();
        Set<TableSource> requiredTables = requiredColumns.getTables();

        estimator.spatialIndex(index);

        if (!index.isCovering()) {
            estimator.flatten(tables, index.getLeafMostTable(), requiredTables);
        }

        Collection<ConditionExpression> unhandledConditions = new HashSet<>(requiredConditions);
        if (index.getConditions() != null)
            unhandledConditions.removeAll(index.getConditions());
        if (!unhandledConditions.isEmpty()) {
            estimator.select(unhandledConditions,
                             selectivityConditions(unhandledConditions, requiredTables));
        }

        if (queryGoal.needSort(index.getOrderEffectiveness())) {
            estimator.sort(queryGoal.sortFields());
        }

        estimator.setLimit(queryGoal.getLimit());

        return estimator.getCostEstimate();
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.rule.cost.PlanCostEstimator

        Set<TableSource> required = new HashSet<>(requiredAfter.getTables());
        scan.setRequiredTables(required);
    }

    public CostEstimate estimateCostFullText(FullTextScan scan) {
        PlanCostEstimator estimator = newEstimator();
        estimator.fullTextScan(scan);
        return estimator.getCostEstimate();
    }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.rule.cost.PlanCostEstimator

        estimator.fullTextScan(scan);
        return estimator.getCostEstimate();
    }

    protected PlanCostEstimator newEstimator() {
        return new PlanCostEstimator(queryGoal.getCostEstimator());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.