[SERVER-27060] Distinct not using the index on an indexed array field Created: 16/Nov/16  Updated: 16/Nov/16  Resolved: 16/Nov/16

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 3.2.10
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Stephane Marquis Assignee: David Storch
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-13298 distinct doesn't use index to distinc... Closed
Operating System: ALL
Participants:

 Description   

Hi !
We have a collection which is roughly based on a schema similar to :

{
  _id : GUID
  StartTime: DateTime
  // Other Information
  Counters: [  
    {
         Name : string,
        // Others informations...
    }
   ]
}

And I have that index on the collection :

{'Counters.Name' : 1 }

In our application, we want to use the Counters.Name as a filter (basically display it in a dropdown list). However, using :

db.sessions.explain().distinct('Counters.Name')

The winning plan is a full COLLSCAN.



 Comments   
Comment by David Storch [ 16/Nov/16 ]

Hi smarquis,

You are correct that the server currently cannot use a multikey index to compute the distinct values of a dotted path. This looks like a duplicate of SERVER-13298. Please watch and vote for this ticket. Let me know if you have any questions or concerns.

Best,
Dave

Generated at Thu Feb 08 04:14:03 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.