[SERVER-23561] Distinct on sub-documents array doesn't use index Created: 06/Apr/16 Updated: 16/Nov/21 Resolved: 06/Apr/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance |
| Affects Version/s: | 3.2.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Tom Grossman | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Operating System: | ALL | ||||||||||||
| Steps To Reproduce: |
|
||||||||||||
| Participants: | |||||||||||||
| Description |
|
If there is an index on a field in an array of sub-documents, distinct on this field doesn't use the index. For example, I have the following collection schema:
And I have the following index:
If I run the following command:
I can see that the planSummary uses COLLSCAN and not DISTINCT_SCAN as I expected. |
| Comments |
| Comment by J Rassi [ 06/Apr/16 ] |
|
Unfortunately, MongoDB doesn't support covered queries on dotted fields at the moment. Support for this feature is being tracked at On a related note, I've discovered while investigating this issue that MongoDB does incorrectly generate DISTINCT_SCAN plans for dotted fields if the index is not multi-key. I've filed |