Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27060

Distinct not using the index on an indexed array field

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

      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@mongodb.com David Storch
            Reporter:
            smarquis Stephane Marquis
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: