/** * Constructs an instance of PostgresExplainResult without any data. * * @param q the Query to explain * */ public DummyExplainResult(Query q) { time = 300 * (q.getFrom().size() + q.getWhere().size()); }
/** * Constructs an instance of PostgresExplainResult without any data. * * @param q the Query to explain * */ public DummyExplainResult(Query q) { time = 300 * (q.getFrom().size() + q.getWhere().size()); }
private static void populateWhereClause(PrecomputedTable precomputedTable, Query query, Query precompQuery, Map<AbstractValue, SelectValue> valueMap, Query currentQuery, Set<AbstractConstraint> whereConstraintEqualsSet, Table precomputedSqlTable, Query newQuery, Field orderByField, List<AbstractValue> precompOrderBy) throws QueryOptimiserException { if ((orderByField == null) || (!query.getGroupBy().isEmpty())) { reconstructAbstractConstraints(currentQuery.getWhere(), precomputedSqlTable, valueMap, precompQuery.getFrom(), false, newQuery.getWhere(), whereConstraintEqualsSet, null, 0, null, false, false); } else { AbstractValue maybeDesc = precompOrderBy.get(0); boolean reverse = false; if (maybeDesc instanceof OrderDescending) { maybeDesc = ((OrderDescending) maybeDesc).getValue(); reverse = true; } Field firstPrecompOrderBy = new Field(valueMap.get( maybeDesc).getAlias(), precomputedSqlTable); reconstructAbstractConstraints(currentQuery.getWhere(), precomputedSqlTable, valueMap, precompQuery.getFrom(), false, newQuery.getWhere(), whereConstraintEqualsSet, firstPrecompOrderBy, precompOrderBy.size(), orderByField, precomputedTable.getFirstOrderByHasNoNulls(), reverse); } }
private static void populateWhereClause(PrecomputedTable precomputedTable, Query query, Query precompQuery, Map<AbstractValue, SelectValue> valueMap, Query currentQuery, Set<AbstractConstraint> whereConstraintEqualsSet, Table precomputedSqlTable, Query newQuery, Field orderByField, List<AbstractValue> precompOrderBy) throws QueryOptimiserException { if ((orderByField == null) || (!query.getGroupBy().isEmpty())) { reconstructAbstractConstraints(currentQuery.getWhere(), precomputedSqlTable, valueMap, precompQuery.getFrom(), false, newQuery.getWhere(), whereConstraintEqualsSet, null, 0, null, false, false); } else { AbstractValue maybeDesc = precompOrderBy.get(0); boolean reverse = false; if (maybeDesc instanceof OrderDescending) { maybeDesc = ((OrderDescending) maybeDesc).getValue(); reverse = true; } Field firstPrecompOrderBy = new Field(valueMap.get( maybeDesc).getAlias(), precomputedSqlTable); reconstructAbstractConstraints(currentQuery.getWhere(), precomputedSqlTable, valueMap, precompQuery.getFrom(), false, newQuery.getWhere(), whereConstraintEqualsSet, firstPrecompOrderBy, precompOrderBy.size(), orderByField, precomputedTable.getFirstOrderByHasNoNulls(), reverse); } }
public void testCompareConstraints() throws Exception { Set equalsSet = new HashSet(); assertTrue(QueryOptimiser.compareConstraints(twoSameTableQuery.getWhere(), twoSameTableQuery.getWhere(), equalsSet)); assertEquals(twoSameTableQuery.getWhere(), equalsSet); equalsSet = new HashSet(); assertTrue(QueryOptimiser.compareConstraints(singleTableQueryNoConstraints.getWhere(), singleTableQuery.getWhere(), equalsSet)); assertEquals(singleTableQueryNoConstraints.getWhere(), equalsSet); equalsSet = new HashSet(); assertTrue(QueryOptimiser.compareConstraints(singleTableQueryWithTableAlias.getWhere(), twoSameTableQuery.getWhere(), equalsSet)); assertEquals(singleTableQueryWithTableAlias.getWhere(), equalsSet); equalsSet = new HashSet(); assertFalse(QueryOptimiser.compareConstraints(singleTableQuery.getWhere(), singleTableQueryNoConstraints.getWhere(), equalsSet)); // equalsSet is now undefined. equalsSet = new HashSet(); assertFalse(QueryOptimiser.compareConstraints(twoSameTableQuery.getWhere(), singleTableQueryWithTableAlias.getWhere(), equalsSet)); // equalsSet is now undefined. }
Collection<Map<AbstractTable, AbstractTable>> c = MappingUtil.findCombinations(precompQuery .getFrom(), query.getFrom(), new AbstractTableComparator(), new OptimiserMappingChecker(precompQuery.getWhere(), query.getWhere())); mappings.addAll(c); = new LinkedHashSet<AbstractConstraint>(); if (!compareConstraints(precompQuery.getWhere(), query.getWhere(), whereConstraintEqualsSet)) { mappingsIter.remove(); = new LinkedHashSet<AbstractConstraint>(); compareConstraints(precompQuery.getWhere(), currentQuery.getWhere(), whereConstraintEqualsSet);
Collection<Map<AbstractTable, AbstractTable>> c = MappingUtil.findCombinations(precompQuery .getFrom(), query.getFrom(), new AbstractTableComparator(), new OptimiserMappingChecker(precompQuery.getWhere(), query.getWhere())); mappings.addAll(c); = new LinkedHashSet<AbstractConstraint>(); if (!compareConstraints(precompQuery.getWhere(), query.getWhere(), whereConstraintEqualsSet)) { mappingsIter.remove(); = new LinkedHashSet<AbstractConstraint>(); compareConstraints(precompQuery.getWhere(), currentQuery.getWhere(), whereConstraintEqualsSet);