-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: 3.2.4
-
Component/s: Index Maintenance
-
None
-
ALL
-
- Create doc with sub-docs array
- Create an index on one of the sub-docs fields
- Distinct on that field
-
None
-
None
-
None
-
None
-
None
-
None
-
None
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.
- 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
-