[SERVER-81792] Optimize $exists and $ne: null in the boolean expression simplifier Created: 03/Oct/23  Updated: 01/Nov/23

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Alexander Ignatyev Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Issue split
split from SERVER-75079 Simplify boolean expressions before f... Closed
Related
related to SERVER-35018 remove unnecessary FETCH from plan wh... Backlog
Assigned Teams:
Query Optimization
Participants:

 Description   

1. If we have a positive predicate and {$exists: true} in one conjunction we can remove {$exists: true}. E.g.

{a: {$eq: 1, $exists: true}} == {a: 1}


2. The same idea with {$ne: null}:

{a: {$eq: 1, $ne: null}} == {a: 1}


3. A positive predicate and {$exists: false}:

{a: {$eq: 1, $exists: false}} == {$alwaysFalse: true}


4. A negative predicate and {$exists: false}:

{a: {$ne: 1, $exists: false}} == {a: {$ne: 1}}


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