[SERVER-83883] Simplify elemMatch expressions containing one single trivially false component to alwaysFalse Created: 05/Dec/23  Updated: 13/Dec/23  Resolved: 13/Dec/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Carlos Alonso Pérez Assignee: Carlos Alonso Pérez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
Backwards Compatibility: Fully Compatible
Participants:
Linked BF Score: 120

 Description   

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



 Comments   
Comment by Githook User [ 12/Dec/23 ]

Author:

{'name': 'Carlos Alonso', 'email': 'c.alonso@mongodb.com', 'username': 'calonso'}

Message: SERVER-83883 Optimize elemMatch expression when trivially false

GitOrigin-RevId: 9a852c75bc9e81123ab6566251ae07d23d2fb64d
Branch: master
https://github.com/mongodb/mongo/commit/d9cf758c52e7caedd1acfa10c781cda13adc8f73

Generated at Thu Feb 08 06:53:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.