mirror of https://gitee.com/bigwinds/arangodb
Allow the optimizer to use indexes (#10543)
* Allow the optimizer to use indexes when a collection attribute is compared to anexpansion followed by an attribute name, e.g. `doc.value IN something[*].name`. * Update CHANGELOG
This commit is contained in:
parent
752dd7fdd5
commit
76f84f2c6c
|
@ -1,6 +1,10 @@
|
||||||
v3.5.3 (XXXX-XX-XX)
|
v3.5.3 (XXXX-XX-XX)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* Allow the optimizer to use indexes when a collection attribute is compared to
|
||||||
|
an expansion followed by an attribute name, e.g.
|
||||||
|
`doc.value IN something[*].name`.
|
||||||
|
|
||||||
* Updated arangosync to 0.7.0.
|
* Updated arangosync to 0.7.0.
|
||||||
|
|
||||||
* Fixed issue #10470: The WebUI now shows potential errors and details which
|
* Fixed issue #10470: The WebUI now shows potential errors and details which
|
||||||
|
|
|
@ -825,8 +825,7 @@ bool Index::canUseConditionPart(arangodb::aql::AstNode const* access,
|
||||||
other->type == arangodb::aql::NODE_TYPE_ATTRIBUTE_ACCESS)) {
|
other->type == arangodb::aql::NODE_TYPE_ATTRIBUTE_ACCESS)) {
|
||||||
// value IN a.b OR value IN a.b[*]
|
// value IN a.b OR value IN a.b[*]
|
||||||
arangodb::aql::Ast::getReferencedVariables(access, variables);
|
arangodb::aql::Ast::getReferencedVariables(access, variables);
|
||||||
if (other->type == arangodb::aql::NODE_TYPE_ATTRIBUTE_ACCESS &&
|
if (variables.find(reference) != variables.end()) {
|
||||||
variables.find(reference) != variables.end()) {
|
|
||||||
variables.clear();
|
variables.clear();
|
||||||
arangodb::aql::Ast::getReferencedVariables(other, variables);
|
arangodb::aql::Ast::getReferencedVariables(other, variables);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,40 @@ function optimizerIndexesTestSuite () {
|
||||||
db._drop("UnitTestsCollection");
|
db._drop("UnitTestsCollection");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
testIndexUsedForExpansion1 : function () {
|
||||||
|
let query = "LET test = NOOPT([{ value: 1 }, { value : 2 }]) FOR doc IN " + c.name() + " FILTER doc.value IN test[*].value SORT doc.value RETURN doc.value";
|
||||||
|
|
||||||
|
let plan = AQL_EXPLAIN(query).plan;
|
||||||
|
let nodeTypes = plan.nodes.map(function(node) {
|
||||||
|
return node.type;
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||||
|
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||||
|
|
||||||
|
let results = AQL_EXECUTE(query);
|
||||||
|
assertEqual([ 1, 2 ], results.json, query);
|
||||||
|
assertEqual(0, results.stats.scannedFull);
|
||||||
|
assertTrue(results.stats.scannedIndex > 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
testIndexUsedForExpansion2 : function () {
|
||||||
|
let query = "LET test = NOOPT([1, 2]) FOR doc IN " + c.name() + " FILTER doc.value IN test[*] SORT doc.value RETURN doc.value";
|
||||||
|
|
||||||
|
let plan = AQL_EXPLAIN(query).plan;
|
||||||
|
let nodeTypes = plan.nodes.map(function(node) {
|
||||||
|
return node.type;
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEqual("SingletonNode", nodeTypes[0], query);
|
||||||
|
assertNotEqual(-1, nodeTypes.indexOf("IndexNode"), query);
|
||||||
|
|
||||||
|
let results = AQL_EXECUTE(query);
|
||||||
|
assertEqual([ 1, 2 ], results.json, query);
|
||||||
|
assertEqual(0, results.stats.scannedFull);
|
||||||
|
assertTrue(results.stats.scannedIndex > 0);
|
||||||
|
},
|
||||||
|
|
||||||
testMultiIndexesOrCondition : function () {
|
testMultiIndexesOrCondition : function () {
|
||||||
let values = [
|
let values = [
|
||||||
[ "abc", true, true ],
|
[ "abc", true, true ],
|
||||||
|
|
Loading…
Reference in New Issue