[SERVER-61787] A $match stage with a top $and with only one $or fails to be pushed down together with $group Created: 29/Nov/21  Updated: 29/Oct/23  Resolved: 30/Nov/21

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

Type: Bug Priority: Major - P3
Reporter: Yoon Soo Kim Assignee: Yoon Soo Kim
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to SERVER-60191 A $match and $group pipeline fails wh... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

db.t.aggregate([{$match: {$and: [{$or: [{"n": {$gt: 1000}}, {"n": {$lt: -1000}}]}]}}, {$group: {_id: null, max: {$max: "$n"}}}])

Sprint: QE 2021-12-13
Participants:
Linked BF Score: 45

 Description   

The issue here is related to subplanning for $or condition of $match stage. The $and in the repro has only one $or element and I expect that $and would be optimized away and $or would be the top expression but the following code can not detect that.

https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/pipeline_d.cpp#L121-L125



 Comments   
Comment by Githook User [ 30/Nov/21 ]

Author:

{'name': 'Yoonsoo Kim', 'email': 'yoonsoo.kim@mongodb.com', 'username': 'yun-soo'}

Message: SERVER-61787 Block pushdown of subplanned $match stage
Branch: master
https://github.com/mongodb/mongo/commit/e4fdc9440350c3840bbcba5fa5cdbd86609fcb59

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