Details
-
Bug
-
Resolution: Unresolved
-
Major - P3
-
None
-
None
-
None
-
None
-
Query Optimization
-
ALL
-
QO 2023-12-11, QO 2023-12-25
Description
To reproduce:
// In bonsai M2 mode
|
db.c.drop()
|
db.c.insert({a: {b: 1}}) |
db.c.createIndex({"a.b": 1}) |
db.c.find({$and: [{a: {$elemMatch: {b: {$elemMatch: {$gte: 1, $lte: 4}}}}}, {"a.b": {$in: [2, 5]}}]}).hint({$natural: 1}) |
// In bonsai M4 mode
|
db.c.drop()
|
db.c.insert({a: {b: 1}}) |
db.c.createIndex({"a.b": 1}) |
db.c.find({$and: [{a: {$elemMatch: {b: {$elemMatch: {$gte: 1, $lte: 4}}}}}, {"a.b": {$in: [2, 5]}}]}) |
This results in a uassert that we are inserting an empty value scan into the memo when such a node already exists in the memo in a different group. This occurs due to a combination of rewrites (filter decomposition, multikeyness simplification and filter substitution) resulting in multiple groups being simplified to an empty value scan.
Some options we should consider are relaxing this assertion, allowing identical groups to be merged, and inserting a delegator to the other group in such a case.