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

Covered index not working on sub documents

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.5
    • Component/s: None
    • None

      I have a problem with indexes on subdocuments where indexOnly is always false.

      Take this code for example from the Mongo Docs (altered a bit to resemble my problem):

      db.factories.insert( { name: "xyz", metro:

      { city: "New York", state: "NY" }

      } );
      db.factories.ensureIndex(

      {"metro.city":1}

      );
      db.factories.find(

      { "metro.city" : "New York" }

      , {_id:0, "metro.city" : 1} ).explain();
      Output:
      {
      "cursor" : "BtreeCursor metro.city_1",
      "nscanned" : 1,
      "nscannedObjects" : 1,
      "n" : 1,
      "millis" : 0,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "isMultiKey" : false,
      "indexOnly" : false,
      "indexBounds" :

      { "metro.city" : [ [ "New York", "New York" ] ] }

      }

      Notice the indexOnly is false although an index is used and only indexed values should be returned. Hence the {_id:0, "metro.city" : 1} part.
      Is this because the more than just the metro.city is returned? { "metro" :

      { "city" : "New York" }

      }
      Anybody any idea how I can make sure indexOnly becomes true in this situation?

            Assignee:
            Unassigned Unassigned
            Reporter:
            renedekat René de Kat
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: