Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Fixed
-
None
-
None
-
Fully Compatible
-
ALL
-
QO 2022-12-12, QO 2022-12-26
-
162
Description
I have a set of documents that I insert into a collection, I create a compound index {a: 1, x: 1} and then I run a query:
{$match: {$and: [ { "a.b" : 1 }, { "a.x" : 1 } ]}}
|
The optimizer constructs a plan which fails to match the following document:
{a: [{b: 1}, {x: 1}]}.
|
The plan chosen by the optimizer is an index scan followed by two filters, one for the a.b predicate and one for the a.x predicate, and then the fetch comes later. The problem is that the two filter are applied to the index keys, so only a key that matches both predicates under the $and will pass the filters. But, if ‘a’ is an array, it may have multiple index keys, one which satisfies the first filter and one which satisfies the second. This would match in classic.