/** * TODO: this uses key check is not really accurate, it doesn't take into consideration where * we are in the plan. * if a key column is used after a non 1-1 join or a union all, then it may be non-unique. */ public static boolean usesKey(Collection<? extends Expression> allElements, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { return usesKey(allElements, null, metadata, true); }
/** * TODO: this uses key check is not really accurate, it doesn't take into consideration where * we are in the plan. * if a key column is used after a non 1-1 join or a union all, then it may be non-unique. */ public static boolean usesKey(Collection<? extends Expression> allElements, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { return usesKey(allElements, null, metadata, true); }
/** * TODO: this uses key check is not really accurate, it doesn't take into consideration where * we are in the plan. * if a key column is used after a non 1-1 join or a union all, then it may be non-unique. */ public static boolean usesKey(Collection<? extends Expression> allElements, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { return usesKey(allElements, null, metadata, true); }
public static boolean usesKey(Criteria crit, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { HashSet<ElementSymbol> elements = new HashSet<ElementSymbol>(); collectElementsOfValidCriteria(crit, elements); return usesKey(elements, metadata); }
public static boolean usesKey(Criteria crit, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { HashSet<ElementSymbol> elements = new HashSet<ElementSymbol>(); collectElementsOfValidCriteria(crit, elements); return usesKey(elements, metadata); }
static boolean usesKey(PlanNode planNode, Collection<? extends Expression> allElements, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { //TODO: key preserved joins should be marked return isSingleTable(planNode) && usesKey(allElements, metadata); }
public static boolean usesKey(Criteria crit, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { HashSet<ElementSymbol> elements = new HashSet<ElementSymbol>(); collectElementsOfValidCriteria(crit, elements); return usesKey(elements, metadata); }
static boolean usesKey(PlanNode planNode, Collection<? extends Expression> allElements, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { //TODO: key preserved joins should be marked return isSingleTable(planNode) && usesKey(allElements, metadata); }
static boolean usesKey(PlanNode planNode, Collection<? extends Expression> allElements, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { //TODO: key preserved joins should be marked return isSingleTable(planNode) && usesKey(allElements, metadata); }
private static float getPredicateNDV(LanguageObject object, PlanNode currentNode, float childCost, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Collection<ElementSymbol> elements = ElementCollectorVisitor.getElements(object, true); Collection<GroupSymbol> groups = GroupsUsedByElementsVisitor.getGroups(elements); boolean multiGroup = groups.size() > 1; float ndv = getStat(Stat.NDV, elements, currentNode, childCost, metadata); if (ndv == UNKNOWN_VALUE) { boolean usesKey = usesKey(elements, metadata); if (multiGroup) { if (usesKey) { ndv = (float)Math.ceil(Math.sqrt(childCost)); } else { ndv = (float)Math.ceil(Math.sqrt(childCost)/4); } } else if (usesKey) { ndv = childCost; } else { ndv = (float)Math.ceil(Math.sqrt(childCost)/2); } ndv = Math.max(ndv, 1); } return ndv; }
private static float getPredicateNDV(LanguageObject object, PlanNode currentNode, float childCost, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Collection<ElementSymbol> elements = ElementCollectorVisitor.getElements(object, true); Collection<GroupSymbol> groups = GroupsUsedByElementsVisitor.getGroups(elements); boolean multiGroup = groups.size() > 1; float ndv = getStat(Stat.NDV, elements, currentNode, childCost, metadata); if (ndv == UNKNOWN_VALUE) { boolean usesKey = usesKey(elements, metadata); if (multiGroup) { if (usesKey) { ndv = (float)Math.ceil(Math.sqrt(childCost)); } else { ndv = (float)Math.ceil(Math.sqrt(childCost)/4); } } else if (usesKey) { ndv = childCost; } else { ndv = (float)Math.ceil(Math.sqrt(childCost)/2); } ndv = Math.max(ndv, 1); } return ndv; }
private static float getPredicateNDV(LanguageObject object, PlanNode currentNode, float childCost, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Collection<ElementSymbol> elements = ElementCollectorVisitor.getElements(object, true); Collection<GroupSymbol> groups = GroupsUsedByElementsVisitor.getGroups(elements); boolean multiGroup = groups.size() > 1; float ndv = getStat(Stat.NDV, elements, currentNode, childCost, metadata); if (ndv == UNKNOWN_VALUE) { boolean usesKey = usesKey(elements, metadata); if (multiGroup) { if (usesKey) { ndv = (float)Math.ceil(Math.sqrt(childCost)); } else { ndv = (float)Math.ceil(Math.sqrt(childCost)/4); } } else if (usesKey) { ndv = childCost; } else { ndv = (float)Math.ceil(Math.sqrt(childCost)/2); } ndv = Math.max(ndv, 1); } return ndv; }
public static boolean isDistinct(Query query, List<Expression> expressions, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { boolean distinct = false; if (query.getGroupBy() != null) { distinct = true; for (Expression groupByExpr : query.getGroupBy().getSymbols()) { if (!expressions.contains(groupByExpr)) { distinct = false; break; } } } if (distinct) { return true; } HashSet<GroupSymbol> keyPreservingGroups = new HashSet<GroupSymbol>(); ResolverUtil.findKeyPreserved(query, keyPreservingGroups, metadata); return NewCalculateCostUtil.usesKey(expressions, keyPreservingGroups, metadata, true); }
public static boolean isDistinct(Query query, List<Expression> expressions, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { boolean distinct = false; if (query.getGroupBy() != null) { distinct = true; for (Expression groupByExpr : query.getGroupBy().getSymbols()) { if (!expressions.contains(groupByExpr)) { distinct = false; break; } } } if (distinct) { return true; } HashSet<GroupSymbol> keyPreservingGroups = new HashSet<GroupSymbol>(); ResolverUtil.findKeyPreserved(query, keyPreservingGroups, metadata); return NewCalculateCostUtil.usesKey(expressions, keyPreservingGroups, metadata, true); }
public static boolean isDistinct(Query query, List<Expression> expressions, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { boolean distinct = false; if (query.getGroupBy() != null) { distinct = true; for (Expression groupByExpr : query.getGroupBy().getSymbols()) { if (!expressions.contains(groupByExpr)) { distinct = false; break; } } } if (distinct) { return true; } HashSet<GroupSymbol> keyPreservingGroups = new HashSet<GroupSymbol>(); ResolverUtil.findKeyPreserved(query, keyPreservingGroups, metadata); return NewCalculateCostUtil.usesKey(expressions, keyPreservingGroups, metadata, true); }
if (cardinality != UNKNOWN_VALUE) { if (ndv == UNKNOWN_VALUE) { if (usesKey(node, Arrays.asList(expr), metadata)) { ndv = cardinality; nnv = 0;
cost = 0; if (isSingleTable(currentNode) && usesKey(compCrit, metadata)) { return 1;
cost = 0; if (isSingleTable(currentNode) && usesKey(compCrit, metadata)) { return 1;