[SERVER-81788] Optimize $elemMatch 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-22857 eliminate redundant conditions/clause... Closed
Assigned Teams:
Query Optimization
Participants:

 Description   
  1. $elemMatch children can be simplified as independent Boolean expressions, then the result could be attached to the parent's BitsetTree. We will need to modify `restoreMatchExpression` function to handle that case.
  2. In the $elemMatch's parent's conjunction contains the same terms as the $elemMatch's conjunction we can remove the terms from the $elemtMatch's conjunction. E.g.

     { "a": {"id":1}, "a":{$elemMatch:{"id":1, "b":9} } } == { "a": {"id":1}, "a":{$elemMatch:{"b":9} } } 

    see SERVER-22857


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