From f5a6818cdb06ad3485d78c7877db222948d77656 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Fri, 3 Feb 2017 11:17:56 +0100 Subject: [PATCH] don't tell GatherNode to sort data from an unsorted index --- arangod/Aql/OptimizerRules.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arangod/Aql/OptimizerRules.cpp b/arangod/Aql/OptimizerRules.cpp index 46c384c7e9..e9f6f7e23a 100644 --- a/arangod/Aql/OptimizerRules.cpp +++ b/arangod/Aql/OptimizerRules.cpp @@ -2350,13 +2350,15 @@ void arangodb::aql::scatterInClusterRule(Optimizer* opt, ExecutionPlan* plan, // Using Index for sort only works if all indexes are equal. auto first = allIndexes[0].getIndex(); - for (auto const& path : first->fieldNames()) { - elements.emplace_back(sortVariable, !isSortReverse, path); - } - for (auto const& it : allIndexes) { - if (first != it.getIndex()) { - elements.clear(); - break; + if (first->isSorted()) { + for (auto const& path : first->fieldNames()) { + elements.emplace_back(sortVariable, !isSortReverse, path); + } + for (auto const& it : allIndexes) { + if (first != it.getIndex()) { + elements.clear(); + break; + } } } } else if (nodeType == ExecutionNode::INSERT ||