/** * @param metadata * @throws QueryMetadataException * @throws TeiidComponentException */ private void estimateCriteriaSelectivity(QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { for (PlanNode node : criteriaNodes) { Criteria crit = (Criteria)node.getProperty(NodeConstants.Info.SELECT_CRITERIA); float[] baseCosts = new float[] {100, 10000, 1000000}; float filterValue = 0; for (int j = 0; j < baseCosts.length; j++) { float filter = NewCalculateCostUtil.recursiveEstimateCostOfCriteria(baseCosts[j], node, crit, metadata); filterValue += filter/baseCosts[j]; } filterValue /= baseCosts.length; node.setProperty(NodeConstants.Info.EST_SELECTIVITY, new Float(filterValue)); } }
/** * @param metadata * @throws QueryMetadataException * @throws TeiidComponentException */ private void estimateCriteriaSelectivity(QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { for (PlanNode node : criteriaNodes) { Criteria crit = (Criteria)node.getProperty(NodeConstants.Info.SELECT_CRITERIA); float[] baseCosts = new float[] {100, 10000, 1000000}; float filterValue = 0; for (int j = 0; j < baseCosts.length; j++) { float filter = NewCalculateCostUtil.recursiveEstimateCostOfCriteria(baseCosts[j], node, crit, metadata); filterValue += filter/baseCosts[j]; } filterValue /= baseCosts.length; node.setProperty(NodeConstants.Info.EST_SELECTIVITY, new Float(filterValue)); } }
/** * @param metadata * @throws QueryMetadataException * @throws TeiidComponentException */ private void estimateCriteriaSelectivity(QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { for (PlanNode node : criteriaNodes) { Criteria crit = (Criteria)node.getProperty(NodeConstants.Info.SELECT_CRITERIA); float[] baseCosts = new float[] {100, 10000, 1000000}; float filterValue = 0; for (int j = 0; j < baseCosts.length; j++) { float filter = NewCalculateCostUtil.recursiveEstimateCostOfCriteria(baseCosts[j], node, crit, metadata); filterValue += filter/baseCosts[j]; } filterValue /= baseCosts.length; node.setProperty(NodeConstants.Info.EST_SELECTIVITY, new Float(filterValue)); } }
/** * Estimate the cost of a selection. This is not easy to do without information * about the value count for each relation attribute. * @param metadata */ private static void estimateSelectNodeCost(PlanNode node, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { PlanNode child = node.getFirstChild(); float childCost = child.getCardinality(); //Get list of conjuncts Criteria selectCriteria = (Criteria)node.getProperty(NodeConstants.Info.SELECT_CRITERIA); float newCost = recursiveEstimateCostOfCriteria(childCost, node, selectCriteria, metadata); setCardinalityEstimate(node, newCost, true, metadata); }
/** * Estimate the cost of a selection. This is not easy to do without information * about the value count for each relation attribute. * @param metadata */ private static void estimateSelectNodeCost(PlanNode node, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { PlanNode child = node.getFirstChild(); float childCost = child.getCardinality(); //Get list of conjuncts Criteria selectCriteria = (Criteria)node.getProperty(NodeConstants.Info.SELECT_CRITERIA); float newCost = recursiveEstimateCostOfCriteria(childCost, node, selectCriteria, metadata); setCardinalityEstimate(node, newCost, true, metadata); }
/** * Estimate the cost of a selection. This is not easy to do without information * about the value count for each relation attribute. * @param metadata */ private static void estimateSelectNodeCost(PlanNode node, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { PlanNode child = node.getFirstChild(); float childCost = child.getCardinality(); //Get list of conjuncts Criteria selectCriteria = (Criteria)node.getProperty(NodeConstants.Info.SELECT_CRITERIA); float newCost = recursiveEstimateCostOfCriteria(childCost, node, selectCriteria, metadata); setCardinalityEstimate(node, newCost, true, metadata); }
float nextCost = recursiveEstimateCostOfCriteria(childCost, currentNode, critPart, metadata); return UNKNOWN_VALUE; float nextCost = recursiveEstimateCostOfCriteria(childCost, currentNode, ((NotCriteria)crit).getCriteria(), metadata); if (nextCost == UNKNOWN_VALUE){ return childCost;
float nextCost = recursiveEstimateCostOfCriteria(childCost, currentNode, critPart, metadata); return UNKNOWN_VALUE; float nextCost = recursiveEstimateCostOfCriteria(childCost, currentNode, ((NotCriteria)crit).getCriteria(), metadata); if (nextCost == UNKNOWN_VALUE){ return childCost;
float nextCost = recursiveEstimateCostOfCriteria(childCost, currentNode, critPart, metadata); return UNKNOWN_VALUE; float nextCost = recursiveEstimateCostOfCriteria(childCost, currentNode, ((NotCriteria)crit).getCriteria(), metadata); if (nextCost == UNKNOWN_VALUE){ return childCost;
void helpTestEstimateCost(String critString, float childCost, float expectedResult, QueryMetadataInterface metadata) throws Exception { Criteria crit = helpGetCriteria(critString, metadata); PlanNode select = RelationalPlanner.createSelectNode(crit, false); float resultCost = NewCalculateCostUtil.recursiveEstimateCostOfCriteria(childCost, select, crit, metadata); assertEquals((int)expectedResult, (int)resultCost); }
baseCost = recursiveEstimateCostOfCriteria(baseCost, node, crit, metadata);
baseCost = recursiveEstimateCostOfCriteria(baseCost, node, crit, metadata);
baseCost = recursiveEstimateCostOfCriteria(baseCost, node, crit, metadata);