8000 covering index wins late materialization by iurii-i-popov · Pull Request #10673 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

covering index wins late materialization #10673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
invalid -> valid
  • Loading branch information
Yuriy Popov committed Dec 12, 2019
commit 10ac4c3f30b1f997478619161119bc8f6e66e60f
12 changes: 6 additions & 6 deletions arangod/Aql/IResearchViewOptimizerRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,13 @@ void lateDocumentMaterializationArangoSearchRule(Optimizer* opt,
if (currentUsedVars.find(&viewNode.outVariable()) != currentUsedVars.end()) {
// currently only calculation nodes expected to use a loop variable with attributes
// we successfully replace all references to the loop variable
auto invalid = true;
auto valid = false;
switch (type) {
case ExecutionNode::CALCULATION: {
auto calcNode = ExecutionNode::castTo<CalculationNode*>(current);
if (viewNodeState.canVariablesBeReplaced(calcNode)) {
calcNodes.emplace_back(calcNode);
invalid = false;
valid = true;
}
break;
}
Expand All @@ -401,8 +401,8 @@ void lateDocumentMaterializationArangoSearchRule(Optimizer* opt,
::arangodb::containers::SmallVector<ExecutionNode*> subqueryCalcNodes{sa};
// find calculation nodes in the plan of a subquery
CalculationNodeVarFinder finder(&viewNode.outVariable(), subque 8000 ryCalcNodes);
invalid = subquery->walk(finder);
if (!invalid) { // if the finder did not stop
valid = !subquery->walk(finder);
if (valid) { // if the finder did not stop
for (auto scn : subqueryCalcNodes) {
TRI_ASSERT(scn->getType() == ExecutionNode::CALCULATION);
currentUsedVars.clear();
Expand All @@ -412,7 +412,7 @@ void lateDocumentMaterializationArangoSearchRule(Optimizer* opt,
if (viewNodeState.canVariablesBeReplaced(calcNode)) {
calcNodes.emplace_back(calcNode);
} else {
invalid = true;
valid = false;
break;
}
}
Expand All @@ -423,7 +423,7 @@ void lateDocumentMaterializationArangoSearchRule(Optimizer* opt,
default:
break;
}
if (invalid) {
if (!valid) {
if (sortNode != nullptr) {
// we have a doc body used before selected SortNode
// forget it, let`s look for better sort to use
Expand Down
28 changes: 14 additions & 14 deletions arangod/Aql/IndexNodeOptimizerRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ namespace {
// find attributes referenced to index node out variable
if (!latematerialized::getReferencedAttributes(astNode, indexNode->outVariable(), node)) {
// is not safe for optimization
return true;
return false;
} else if (!node.attrs.empty()) {
if (!attributesMatch(commonIndexId, indexNode, node)) {
return true;
return false;
} else {
nodesToChange.emplace_back(std::move(node));
}
}
return false;
return true;
}
}

Expand Down Expand Up @@ -128,7 +128,7 @@ void arangodb::aql::lateDocumentMaterializationRule(Optimizer* opt,
std::vector<latematerialized::NodeWithAttrs> nodesToChange;
TRI_idx_iid_t commonIndexId = 0; // use one index only
while (current != loop) {
auto invalid = false;
auto valid = true;
auto type = current->getType();
switch (type) {
case ExecutionNode::SORT:
Expand All @@ -137,8 +137,8 @@ void arangodb::aql::lateDocumentMaterializationRule(Optimizer* opt,
}
break;
case ExecutionNode::CALCULATION:
invalid = processCalculationNode(indexNode, ExecutionNode::castTo<CalculationNode*>(current),
nodesToChange, commonIndexId);
valid = processCalculationNode(indexNode, ExecutionNode::castTo<CalculationNode*>(current),
nodesToChange, commonIndexId);
break;
case ExecutionNode::REMOTE:
// REMOTE node is a blocker - we do not want to make materialization calls across cluster!
Expand All @@ -151,28 +151,28 @@ void arangodb::aql::lateDocumentMaterializationRule(Optimizer* opt,
}
// currently only calculation nodes expected to use a loop variable with attributes
// we successfully replace all references to the loop variable
if (!(stopSearch || invalid) && type != ExecutionNode::CALCULATION) {
if (!stopSearch && valid && type != ExecutionNode::CALCULATION) {
arangodb::containers::HashSet<Variable const*> currentUsedVars;
current->getVariablesUsedHere(currentUsedVars);
if (currentUsedVars.find(indexNode->outVariable()) != currentUsedVars.end()) {
invalid = true;
valid = false;
if (ExecutionNode::SUBQUERY == type) {
auto subqueryNode = ExecutionNode::castTo<SubqueryNode*>(current);
auto subquery = subqueryNode->getSubquery();
arangodb::containers::SmallVector<ExecutionNode*>::allocator_type::arena_type sa;
arangodb::containers::SmallVector<ExecutionNode*> subqueryCalcNodes{sa};
// find calculation nodes in the plan of a subquery
CalculationNodeVarFinder finder(indexNode->outVariable(), subqueryCalcNodes);
invalid = subquery->walk(finder);
if (!invalid) { // if the finder did not stop
valid = !subquery->walk(finder);
if (valid) { // if the finder did not stop
for (auto scn : subqueryCalcNodes) {
TRI_ASSERT(scn->getType() == ExecutionNode::CALCULATION);
currentUsedVars.clear();
scn->getVariablesUsedHere(currentUsedVars);
if (currentUsedVars.find(indexNode->outVariable()) != currentUsedVars.end()) {
invalid = processCalculationNode(indexNode, ExecutionNode::castTo<CalculationNode*>(scn),
nodesToChange, commonIndexId);
if (invalid) {
valid = processCalculationNode(indexNode, ExecutionNode::castTo<CalculationNode*>(scn),
nodesToChange, commonIndexId);
if (!valid) {
break;
}
}
Expand All @@ -181,7 +181,7 @@ void arangodb::aql::lateDocumentMaterializationRule(Optimizer* opt,
}
}
}
if (invalid) {
if (!valid) {
TRI_ASSERT(!stopSearch);
if (sortNode != nullptr) {
// we have a doc body used before selected SortNode
Expand Down
0