[SERVER-72651] $match filter is erroneously pushed past $project into COLLSCAN Created: 09/Jan/23 Updated: 29/Oct/23 Resolved: 19/Jan/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 6.0.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Steve Tarzia | Assignee: | Steve Tarzia |
| 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: | On v6.0:
Mongo v6.0 will erroneously generate the following plan for the aggregation:
The filter is merged into the collscan, putting the filter before the projection. This is problematic because the semantics of the filter are different when operating on the full (unprojected) document. The correct plan, produced by v6.1, is:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sprint: | QE 2023-01-23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Linked BF Score: | 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
A $match filter can be pushed past a $project into a COLLSCAN only if the $project has no impact on the filter results. For this to be true, the $match filters' paths must be a subset of the $project paths. This check seems to be broken in v6.0. This ticket came out of rui.liu@mongodb.com's investigation of BF-27387. This issue is only seen in v6.0 because it was fixed for 6.1.0-rc0 by a change to isIndependentOf in v5.0 does not exhibit this bug. |
| Comments |
| Comment by Githook User [ 19/Jan/23 ] | ||||||||
|
Author: {'name': 'Steve Tarzia', 'email': 'steve.tarzia@mongodb.com', 'username': 'starzia'}Message: | ||||||||
| Comment by Steve Tarzia [ 18/Jan/23 ] | ||||||||
|
a more minimal repro of the issue is:
| ||||||||
| Comment by Steve Tarzia [ 13/Jan/23 ] | ||||||||
|
I verified that v5.0 does not exhibit this bug. |