Loading...
Loading...
When a CWI index is used with a $ne: null predicate on a non-wildcard indexed field alongside a wildcard-field predicate, the query planner now inserts an unnecessary FETCH stage. This is a regression introduced by SERVER-95374. A regular non-sparse compound index, a non-wildcard sparse index, and a non-wildcard sparse compound index all produce covered plans for $ne: null. CWI matched this behaviour before SERVER-95374. Example db.demo.drop(); db.demo.createIndex({ "w.$**": 1, unit: 1 }); db.demo.insertMany([ { w: { x: "A" }, unit: 1 }, { w: { x: "A" }, unit: 2 }, { w: { x: "B" }, unit: 3 }, { w: { x: "B" }, unit: 4 }, ]); Before SERVER-95374, this query was covered (totalDocsExamined = 0, PROJECTION_COVERED): db.demo.aggregate([ { $match: { "w.x": "A", unit: { $ne: null } } }, { $project: { _id: 0, unit: 1 } }, ]); After SERVER-95374 it produces PROJECTION_SIMPLE with a FETCH stage and totalDocsExamined = 4. Fix traverseAndPropagateANDRelatedPredicates strips index assignments from all $not nodes unconditionally, rather than applying the same $ne: null exception that nodeIsSupportedBySparseIndex already carves out for sparse indexes. Smarter stripping logic - analogous to that can restore the pre-regression behaviour.
MongoDB Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.