diff options
-rw-r--r-- | jstests/noPassthrough/lookup_pushdown.js | 10 | ||||
-rw-r--r-- | src/mongo/db/query/planner_analysis.cpp | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/jstests/noPassthrough/lookup_pushdown.js b/jstests/noPassthrough/lookup_pushdown.js index 1f91a4abecf..b14ab066437 100644 --- a/jstests/noPassthrough/lookup_pushdown.js +++ b/jstests/noPassthrough/lookup_pushdown.js @@ -306,6 +306,16 @@ function setLookupPushdownDisabled(value) { assert.commandWorked(foreignColl.dropIndexes()); })(); +// Construct an index with a partial filter expression. In this case, we should NOT use INLJ. +(function testPartialFilterExpressionIndexesAreIgnored() { + assert.commandWorked(foreignColl.dropIndexes()); + assert.commandWorked(foreignColl.createIndex({b: 1}, {partialFilterExpression: {b: 1}})); + runTest(coll, + [{$lookup: {from: foreignCollName, localField: "a", foreignField: "b", as: "out"}}], + JoinAlgorithm.NLJ /* expectedJoinAlgorithm */); + assert.commandWorked(foreignColl.dropIndexes()); +})(); + // Build a hashed index on the foreign collection that matches the foreignField. Indexed nested loop // join strategy should be used. (function testIndexNestedLoopJoinHashedIndex() { diff --git a/src/mongo/db/query/planner_analysis.cpp b/src/mongo/db/query/planner_analysis.cpp index 654fa0f56ca..af4777dc0e2 100644 --- a/src/mongo/db/query/planner_analysis.cpp +++ b/src/mongo/db/query/planner_analysis.cpp @@ -662,7 +662,7 @@ void QueryPlannerAnalysis::determineLookupStrategy( if ((index.type == INDEX_BTREE || index.type == INDEX_HASHED) && index.keyPattern.firstElement().fieldName() == eqLookupNode->joinFieldForeign.fullPath() && - CollatorInterface::collatorsMatch(collator, index.collator)) { + !index.filterExpr && CollatorInterface::collatorsMatch(collator, index.collator)) { return index; } } |