Skip to content

Commit

Permalink
Bugfix CORE-5435: Badly selective index could be used for extra filte…
Browse files Browse the repository at this point in the history
…ring even if selective index is used for sorting
  • Loading branch information
dyemanov committed Jan 5, 2017
1 parent 1cb8775 commit e4f7a6d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/jrd/Optimizer.cpp
Expand Up @@ -1273,6 +1273,16 @@ InversionCandidate* OptimizerRetrieval::makeInversion(InversionCandidateList* in
matches.add(segment->matches[j]);
}
}

// If the navigational candidate includes any matching segments,
// reset the selectivity/cost prerequisites to account these matches
if (matchedSegments)
{
totalSelectivity = navigationCandidate->selectivity;
totalIndexCost = DEFAULT_INDEX_COST + totalSelectivity * navigationCandidate->cardinality;
previousTotalCost = totalIndexCost + totalSelectivity * streamCardinality;
firstCandidate = false;
}
}

for (i = 0; i < inversions->getCount(); i++)
Expand Down

0 comments on commit e4f7a6d

Please sign in to comment.