mirror of https://gitee.com/bigwinds/arangodb
make optimizer not skip "use-indexes-rule", even if enough plans have been created already
This commit is contained in:
parent
9593ac122d
commit
1769299e95
|
@ -871,6 +871,10 @@ void AstNode::dump(int level) const {
|
||||||
if (type == NODE_TYPE_VALUE || type == NODE_TYPE_ARRAY) {
|
if (type == NODE_TYPE_VALUE || type == NODE_TYPE_ARRAY) {
|
||||||
std::unique_ptr<TRI_json_t> json(toJsonValue(TRI_UNKNOWN_MEM_ZONE));
|
std::unique_ptr<TRI_json_t> json(toJsonValue(TRI_UNKNOWN_MEM_ZONE));
|
||||||
std::cout << ": " << json.get();
|
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";
|
std::cout << "\n";
|
||||||
|
|
||||||
|
|
|
@ -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...
|
// special cases for IN...
|
||||||
if (!isExpanded && !other.isExpanded &&
|
if (!isExpanded && !other.isExpanded &&
|
||||||
other.operatorType == NODE_TYPE_OPERATOR_BINARY_IN &&
|
other.operatorType == NODE_TYPE_OPERATOR_BINARY_IN &&
|
||||||
|
|
|
@ -146,9 +146,13 @@ int Optimizer::createPlans(ExecutionPlan* plan,
|
||||||
level = (*it).first;
|
level = (*it).first;
|
||||||
auto& rule = (*it).second;
|
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 ||
|
if ((runOnlyRequiredRules ||
|
||||||
disabledIds.find(level) != disabledIds.end()) &&
|
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
|
// we picked a disabled rule or we have reached the max number of
|
||||||
// plans
|
// plans
|
||||||
// and just skip this rule
|
// and just skip this rule
|
||||||
|
@ -299,7 +303,7 @@ std::unordered_set<int> Optimizer::getDisabledRuleIds(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// disable a specific rule
|
// 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()) {
|
if (it != _ruleLookup.end()) {
|
||||||
disabled.emplace((*it).second);
|
disabled.emplace((*it).second);
|
||||||
|
@ -311,7 +315,7 @@ std::unordered_set<int> Optimizer::getDisabledRuleIds(
|
||||||
// enable all rules
|
// enable all rules
|
||||||
disabled.clear();
|
disabled.clear();
|
||||||
} else {
|
} else {
|
||||||
auto it = _ruleLookup.find(std::string(name.c_str() + 1));
|
auto it = _ruleLookup.find(name.c_str() + 1);
|
||||||
|
|
||||||
if (it != _ruleLookup.end()) {
|
if (it != _ruleLookup.end()) {
|
||||||
disabled.erase((*it).second);
|
disabled.erase((*it).second);
|
||||||
|
|
Loading…
Reference in New Issue