Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
3.2.4
-
None
-
ALL
-
- Create doc with sub-docs array
- Create an index on one of the sub-docs fields
- Distinct on that field
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:
{
|
"arr" : [ |
{
|
"field_1" : 1, |
"field_2" : 2 |
},
|
{
|
"field_1" : 11, |
"field_2" : 22 |
}
|
]
|
}
|
And I have the following index:
{
|
"arr.field_1" : 1 |
}
|
If I run the following command:
db.runCommand(
|
{
|
distinct: 'test', |
key: 'arr.field_1' |
}
|
)
|
I can see that the planSummary uses COLLSCAN and not DISTINCT_SCAN as I expected.
Attachments
Issue Links
- is related to
-
SERVER-23582 Query planner should not generate DISTINCT_SCAN plan for distinct on dotted field
-
- Closed
-
- related to
-
SERVER-2104 covered index should support dotted fields
-
- Closed
-