1
0
Fork 0

avoid use of geo-index-rule in cases where it could yield an invalid result

This commit is contained in:
Jan Christoph Uhde 2016-12-07 15:06:44 +01:00
parent 3e24624c6e
commit 5416755049
2 changed files with 31 additions and 1 deletions

View File

@ -145,7 +145,7 @@ class Optimizer {
// remove redundant OR conditions
removeRedundantOrRule_pass6 = 820,
applyGeoIndexRule = 1060,
applyGeoIndexRule = 825,
useIndexesRule_pass6 = 830,

View File

@ -4201,6 +4201,7 @@ GeoIndexInfo geoDistanceFunctionArgCheck(std::pair<AstNode*,AstNode*> const& pai
if(setter1 == setter2){
if(setter1->getType() == EN::ENUMERATE_COLLECTION){
auto collNode = reinterpret_cast<EnumerateCollectionNode*>(setter1);
auto coll = collNode->collection(); //what kind of indexes does it have on what attributes
auto lcoll = coll->getCollection();
// TODO - check collection for suitable geo-indexes
@ -4339,6 +4340,35 @@ bool applyGeoOptimization(bool near, ExecutionPlan* plan, GeoIndexInfo& info){
constantPair = &argPair1;
}
// We are not allowed to be a inner loop
if(res.collectionNode->isInInnerLoop()){
return false;
}
//// this works only as long as we just use lists of ExecutionNodes
// avoid other constructs between sort/filter and enumerate collection
ExecutionNode* current = res.executionNode->getFirstDependency();
ExecutionNode* end = res.collectionNode;
while(current != end){
if( current->getType() == EN::SORT
|| current->getType() == EN::COLLECT
|| current->getType() == EN::FILTER
|| current->getType() == EN::ENUMERATE_COLLECTION
|| current->getType() == EN::INDEX
){
return false;
}
current = current->getFirstDependency();
}
// avoid sorts above index node
while(current != plan->root()){
if(current->getType() == EN::SORT){
return false;
}
current = current->getFirstDependency();
}
//LOG_TOPIC(DEBUG, Logger::DEVEL) << " attributes: " << res.longitude[0]
// << ", " << res.longitude
// << " of collection:" << res.collectionNode->collection()->getName()