[SERVER-48488] $group does not use index when grouping on _id attributes Created: 29/May/20 Updated: 29/May/20 Resolved: 29/May/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Olivier Boudet | Assignee: | Carl Champain (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
$group used on partial _id field does not use index. I have a collection with an compound index field. For example like this one :
I want to group over two _id field to work only on distinct values for keys attr1 & attr2. I do this :
The result of this explain query shows that a COLLSCAN is used.
|
| Comments |
| Comment by Carl Champain (Inactive) [ 29/May/20 ] | |
|
The documentation mentions:
So you need to add a $sort stage to the query:
That said, the SERVER project is for bugs and feature suggestions for the MongoDB server. As this ticket does not appear to be a bug, I will now close it. If you need further assistance troubleshooting, I encourage you to ask our community by posting on the MongoDB Community Forums or on Stack Overflow with the mongodb tag. Kind regards, |