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

indexOnly false when query should be covered

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.4.6
    • None
    • None
    • Linux
    • Linux
    • Hide

      db.Test.insert(

      {"_id" : ObjectId("5261ac33e4b070ca9e1480d1"), "date" : ISODate("2013-10-18T21:46:27.476Z"), "disabled" : false, "userHidden" : false, "postId" : NumberLong(103)}

      )

      db.Test.ensureIndex(

      { "postId" : 1, "userHidden" : 1, "disabled" : 1, "date" : -1}

      ,

      {name: "findByPostId", sparse: true, unique: false}

      )

      db.Test.find( { $query:

      {postId: 103, userHidden: false, disabled: false}

      , $orderby:

      {date: -1}

      , $hint: "findByPostId", $explain: 1 },

      {postId: 1, userHidden: 1, disabled: 1, date: 1 }

      ).pretty()

      {
      "cursor" : "BtreeCursor findByPostId",
      "isMultiKey" : false,
      "n" : 1,
      "nscannedObjects" : 1,
      "nscanned" : 1,
      "nscannedObjectsAllPlans" : 1,
      "nscannedAllPlans" : 1,
      "scanAndOrder" : false,
      "indexOnly" : false,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "millis" : 0,
      "indexBounds" : {
      "postId" : [
      [
      103,
      103
      ]
      ],
      "userHidden" : [
      [
      false,
      false
      ]
      ],
      "disabled" : [
      [
      false,
      false
      ]
      ],
      "date" : [
      [

      { "$maxElement" : 1 }

      ,

      { "$minElement" : 1 }

      ]
      ]
      },
      "allPlans" : [
      {
      "cursor" : "BtreeCursor findByPostId",
      "n" : 1,
      "nscannedObjects" : 1,
      "nscanned" : 1,
      "indexBounds" : {
      "postId" : [
      [
      103,
      103
      ]
      ],
      "userHidden" : [
      [
      false,
      false
      ]
      ],
      "disabled" : [
      [
      false,
      false
      ]
      ],
      "date" : [
      [

      { "$maxElement" : 1 }

      ,

      { "$minElement" : 1 }

      ]
      ]
      }
      }
      ],
      "server" : "test-mongo.luvit.net:270"
      }

      According to docs and everything I can find there is no reason this query should not be indexOnly: true and it is false

      Show
      db.Test.insert( {"_id" : ObjectId("5261ac33e4b070ca9e1480d1"), "date" : ISODate("2013-10-18T21:46:27.476Z"), "disabled" : false, "userHidden" : false, "postId" : NumberLong(103)} ) db.Test.ensureIndex( { "postId" : 1, "userHidden" : 1, "disabled" : 1, "date" : -1} , {name: "findByPostId", sparse: true, unique: false} ) db.Test.find( { $query: {postId: 103, userHidden: false, disabled: false} , $orderby: {date: -1} , $hint: "findByPostId", $explain: 1 }, {postId: 1, userHidden: 1, disabled: 1, date: 1 } ).pretty() { "cursor" : "BtreeCursor findByPostId", "isMultiKey" : false, "n" : 1, "nscannedObjects" : 1, "nscanned" : 1, "nscannedObjectsAllPlans" : 1, "nscannedAllPlans" : 1, "scanAndOrder" : false, "indexOnly" : false, "nYields" : 0, "nChunkSkips" : 0, "millis" : 0, "indexBounds" : { "postId" : [ [ 103, 103 ] ], "userHidden" : [ [ false, false ] ], "disabled" : [ [ false, false ] ], "date" : [ [ { "$maxElement" : 1 } , { "$minElement" : 1 } ] ] }, "allPlans" : [ { "cursor" : "BtreeCursor findByPostId", "n" : 1, "nscannedObjects" : 1, "nscanned" : 1, "indexBounds" : { "postId" : [ [ 103, 103 ] ], "userHidden" : [ [ false, false ] ], "disabled" : [ [ false, false ] ], "date" : [ [ { "$maxElement" : 1 } , { "$minElement" : 1 } ] ] } } ], "server" : "test-mongo.luvit.net:270" } According to docs and everything I can find there is no reason this query should not be indexOnly: true and it is false

    Description

      Index does not have fields that are sub documents or arrays and indexOnly is false on what should be a covered query

      Attachments

        Activity

          People

            Unassigned Unassigned
            davidluvit David Wartell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: