-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
120
The definition of an $elemMatch expression is that it matches docs in where all its components are true, hence as soon as one is false the doc is filtered out.
That means we can optimize
$elemMatch: [{a: 1}, {$alwaysFalse: 1}]
to
$alwaysFalse: 1