[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: |
|
||||||||||||
| 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: |