Distinct not using the index on an indexed array field

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.2.10
    • Component/s: Querying
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            David Storch
            Reporter:
            Stephane Marquis
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: