[SERVER-62353] Ensure $or -> $in optimization parity Created: 04/Jan/22  Updated: 29/Oct/23  Resolved: 10/May/23

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

Type: Task Priority: Major - P3
Reporter: Hana Pearlman Assignee: Hana Pearlman
Resolution: Fixed Votes: 0
Labels: optimization
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-34012 Planner's logic for taking union of i... Closed
Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Sprint: QO 2022-03-07
Participants:

 Description   

During pipeline optimization, we currently rewrite a $or with equality conditions on the same path into a $in. That is:

{$or: [{a: 1}, {a: 2}]}

becomes

{a: {$in: [1, 2]}}.

There is also support to rewrite part of a $or as follows:

{$or: [{a: 1}, {a: 2}, {b: 3}]} 

becomes

{$or: [{a: {$in: [1, 2]}}, {b: 3}].

The first part of the optimization (replacing an entire $or with an $in) is supported by the new optimizer in the logical rewrites phase. The second part is not yet supported by the new optimizer. Eventually, when we don't run pipeline optimization before we hit the new optimizer, we'll need to support this behavior in the new optimizer.



 Comments   
Comment by Githook User [ 09/May/23 ]

Author:

{'name': 'Hana Pearlman', 'email': 'hana.pearlman@mongodb.com', 'username': 'HanaPearlman'}

Message: SERVER-62353: Test OR with multiple predicates on the same field
Branch: master
https://github.com/mongodb/mongo/commit/4be23058222baa18cf4704139d3ac63be4c6dcc4

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