-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
Fully Compatible
-
QE 2026-01-05, QE 2025-12-22
-
None
-
None
-
None
-
None
-
None
-
None
-
None
In the pipeline below, the top-level $project should have removed the field x from the result. However, with JOO enabled, the field remains as it was:
db.foo.drop();
db.bar.drop();
db.foo.insertMany([{_id: 1, x: 99999999}]);
db.bar.insertMany([{_id: 1}]);
pipeline = [
{
"$project": {
"d": 1,
}
},
{
"$lookup": {
"from": "bar",
"localField": "_id",
"foreignField": "_id",
"as": "y"
}
},
{
"$unwind": "$y"
},
]
db.adminCommand({setParameter: 1, internalEnableJoinOptimization: false});
db.foo.aggregate(pipeline);
db.adminCommand({setParameter: 1, internalEnableJoinOptimization: true});
db.foo.aggregate(pipeline);
Produces the following:
Enterprise test> db.adminCommand({setParameter: 1, internalEnableJoinOptimization: false});
{ was: true, ok: 1 }
Enterprise test> db.foo.aggregate(pipeline);
[ { _id: 1, y: { _id: 1 } } ] <<<=== CORRECT
Enterprise test>
Enterprise test> db.adminCommand({setParameter: 1, internalEnableJoinOptimization: true});
{ was: false, ok: 1 }
Enterprise test> db.foo.aggregate(pipeline);
[ { _id: 1, x: 99999999, y: { _id: 1 } } ] <<<=== INCORRECT
Enterprise test>