1
0
Fork 0

make optimizer not skip "use-indexes-rule", even if enough plans have been created already

This commit is contained in:
Jan Steemann 2016-07-04 16:30:04 +02:00
parent 9593ac122d
commit 1769299e95
3 changed files with 19 additions and 3 deletions

View File

@ -871,6 +871,10 @@ void AstNode::dump(int level) const {
if (type == NODE_TYPE_VALUE || type == NODE_TYPE_ARRAY) {
std::unique_ptr<TRI_json_t> json(toJsonValue(TRI_UNKNOWN_MEM_ZONE));
std::cout << ": " << json.get();
} else if (type == NODE_TYPE_ATTRIBUTE_ACCESS) {
std::cout << ": " << getString();
} else if (type == NODE_TYPE_REFERENCE) {
std::cout << ": " << static_cast<Variable const*>(getData())->name;
}
std::cout << "\n";

View File

@ -194,6 +194,14 @@ bool ConditionPart::isCoveredBy(ConditionPart const& other, bool isReversed) con
}
}
TRI_ASSERT(valueNode != nullptr);
TRI_ASSERT(other.valueNode != nullptr);
if (!valueNode->isConstant() || !other.valueNode->isConstant()) {
return false;
}
// special cases for IN...
if (!isExpanded && !other.isExpanded &&
other.operatorType == NODE_TYPE_OPERATOR_BINARY_IN &&

View File

@ -146,9 +146,13 @@ int Optimizer::createPlans(ExecutionPlan* plan,
level = (*it).first;
auto& rule = (*it).second;
// skip over rules if we should
// however, we don't want to skip the "use-indexes" rule when it
// was not explicitly deactivated by the caller
if ((runOnlyRequiredRules ||
disabledIds.find(level) != disabledIds.end()) &&
rule.canBeDisabled) {
rule.canBeDisabled &&
(!runOnlyRequiredRules || rule.name != "use-indexes")) {
// we picked a disabled rule or we have reached the max number of
// plans
// and just skip this rule
@ -299,7 +303,7 @@ std::unordered_set<int> Optimizer::getDisabledRuleIds(
}
} else {
// disable a specific rule
auto it = _ruleLookup.find(std::string(name.c_str() + 1));
auto it = _ruleLookup.find(name.c_str() + 1);
if (it != _ruleLookup.end()) {
disabled.emplace((*it).second);
@ -311,7 +315,7 @@ std::unordered_set<int> Optimizer::getDisabledRuleIds(
// enable all rules
disabled.clear();
} else {
auto it = _ruleLookup.find(std::string(name.c_str() + 1));
auto it = _ruleLookup.find(name.c_str() + 1);
if (it != _ruleLookup.end()) {
disabled.erase((*it).second);