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
improvements
  • Loading branch information
Yuriy Popov committed Dec 10, 2019
commit 47913a57c16aea4d73e483754e9a863897825f34
2 changes: 1 addition & 1 deletion arangod/Aql/IndexExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ IndexExecutor::CursorReader::CursorReader(IndexExecutorInfos const& infos,
? Type::LateMaterialized
: !infos.getProduceResult()
? Type::NoResult
: _cursor->hasCovering() &&
: _cursor->hasCovering() && // if change see IndexNode::canApplyLateDocumentMaterializationRule()
!infos.getCoveringIndexAttributePositions().empty()
? Type::Covering
: Type::Document) {
Expand Down
2 changes: 1 addition & 1 deletion arangod/Aql/IndexNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ std::unique_ptr<ExecutionBlock> IndexNode::createBlock(
firstOutputRegister,
getRegisterPlan()->nrRegs[getDepth()], getRegsToClear(),
calcRegsToKeep(), &engine, this->_collection, _outVariable,
(this->isVarUsedLater(_outVariable) || this->_filter != nullptr),
isProduceResult(),
this->_filter.get(), this->projections(),
this->coveringIndexAttributePositions(),
EngineSelectorFeature::ENGINE->useRawDocumentPointers(),
Expand Down
8 changes: 6 additions & 2 deletions arangod/Aql/IndexNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ class IndexNode : public ExecutionNode, public DocumentProducingNode, public Col
return !_outNonMaterializedIndVars.second.empty();
}

bool canApplyLateDocumentMaterializationRule() {
return (isVarUsedLater(_outVariable) || _filter != nullptr) && coveringIndexAttributePositions().empty();
bool canApplyLateDocumentMaterializationRule() const {
return isProduceResult() && coveringIndexAttributePositions().empty();
}

struct IndexVariable {
Expand All @@ -150,6 +150,10 @@ class IndexNode : public ExecutionNode, public DocumentProducingNode, public Col
std::vector<std::unique_ptr<NonConstExpression>>& nonConstExpressions,
transaction::Methods* trxPtr) const;

bool isProduceResult() const {
return isVarUsedLater(_outVariable) || _filter != nullptr;
}

/// @brief adds a UNIQUE() to a dynamic IN condition
arangodb::aql::AstNode* makeUnique(arangodb::aql::AstNode*, transaction::Methods* trx) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ let isCluster = require("internal").isCluster();

function lateDocumentMaterializationRuleTestSuite () {
const ruleName = "late-document-materialization";
const projectionRuleName = "reduce-extraction-to-projection";
const numOfCollectionIndexes = 2;
const numOfExpCollections = 2;
let collectionNames = [];
Expand Down Expand Up @@ -214,6 +215,7 @@ function lateDocumentMaterializationRuleTestSuite () {
let query = "FOR d IN " + projectionsCoveredByIndexCollectionName + " FILTER d.a == 'a_val' SORT d.c LIMIT 10 RETURN d.b";
let plan = AQL_EXPLAIN(query).plan;
assertEqual(-1, plan.rules.indexOf(ruleName));
assertNotEqual(-1, plan.rules.indexOf(projectionRuleName));
},
testNotAppliedDueToSubqueryWithDocumentAccess() {
for (i = 0; i < numOfCollectionIndexes; ++i) {
Expand Down
0