diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-18 17:02:53 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-18 17:02:53 -0300 |
| commit | 959575a5ca598bf5f37fb5cebe7ed1d80d3d71f7 (patch) | |
| tree | acc8d60aedb12b70048e676e8a7349deb0010db8 /src/mongo/db/query/planner_ixselect.cpp | |
| parent | 76588293975fc059cf076779e4283e6ffaf8afff (diff) | |
New upstream version 6.0.20upstream
Diffstat (limited to 'src/mongo/db/query/planner_ixselect.cpp')
| -rw-r--r-- | src/mongo/db/query/planner_ixselect.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/db/query/planner_ixselect.cpp b/src/mongo/db/query/planner_ixselect.cpp index c2e06a1027a..b63484717f2 100644 --- a/src/mongo/db/query/planner_ixselect.cpp +++ b/src/mongo/db/query/planner_ixselect.cpp @@ -256,10 +256,9 @@ void QueryPlannerIXSelect::getFields(const MatchExpression* node, if (Indexability::nodeCanUseIndexOnOwnField(node)) { bool supportSparse = Indexability::nodeSupportedBySparseIndex(node); (*out)[prefix + node->path().toString()] = {supportSparse}; - } else if (Indexability::arrayUsesIndexOnChildren(node) && !node->path().empty()) { + } else if (Indexability::isBoundsGeneratingElemMatchObject(node)) { // If the array uses an index on its children, it's something like // {foo : {$elemMatch: {bar: 1}}}, in which case the predicate is really over foo.bar. - // Note we skip empty path components since they are not allowed in index key patterns. prefix += node->path().toString() + "."; for (size_t i = 0; i < node->numChildren(); ++i) { @@ -440,10 +439,13 @@ bool QueryPlannerIXSelect::_compatible(const BSONElement& keyPatternElt, const auto* child = node->getChild(0); const MatchExpression::MatchType childtype = child->matchType(); - // Can't index negations of MOD, REGEX, TYPE_OPERATOR, or ELEM_MATCH_VALUE. + // Can't index negations of MOD, REGEX, TYPE_OPERATOR, or ELEM_MATCH_VALUE; and, as + // above, we can't use a btree-indexed field for geo expressions (or their negations). if (MatchExpression::REGEX == childtype || MatchExpression::MOD == childtype || MatchExpression::TYPE_OPERATOR == childtype || - MatchExpression::ELEM_MATCH_VALUE == childtype) { + MatchExpression::ELEM_MATCH_VALUE == childtype || + MatchExpression::GEO == childtype || MatchExpression::GEO_NEAR == childtype || + MatchExpression::INTERNAL_BUCKET_GEO_WITHIN == childtype) { return false; } |
