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

Allowed to build {<field>:0} index

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: 2.2.2
    • Component/s: Index Maintenance
    • Environment:
      osx 10.8, ubuntu 12.10, ubuntu 10.10
    • ALL
    • Hide

      1 db.some.insert(

      {a:1}

      )
      2 db.some.ensureIndex(

      {a:0}

      )
      3 db.some.find().sort(

      {a:1}

      ).explain()
      4 db.some.find().sort(

      {a:-1}

      ).explain()

      Show
      1 db.some.insert( {a:1} ) 2 db.some.ensureIndex( {a:0} ) 3 db.some.find().sort( {a:1} ).explain() 4 db.some.find().sort( {a:-1} ).explain()

      it is allowed to create an

      {a:0}

      index. This index has unexpected behavior with sorting

      > db.some.insert(

      {a:1}

      )
      > db.some.ensureIndex(

      {a:0}

      )
      > db.some.find().sort(

      {a:1}

      )

      { "_id" : ObjectId("51254055e6f520cff750a549"), "a" : 1 }

      > db.some.find().sort(

      {a:1}

      ).explain()
      {
      "cursor" : "BtreeCursor a_0 reverse",
      "isMultiKey" : false,
      "n" : 1,
      "nscannedObjects" : 1,
      "nscanned" : 1,
      "nscannedObjectsAllPlans" : 1,
      "nscannedAllPlans" : 1,
      "scanAndOrder" : false,
      "indexOnly" : false,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "millis" : 0,
      "indexBounds" : {
      "a" : [
      [

      { "$maxElement" : 1 }

      ,

      { "$minElement" : 1 }

      ]
      ]
      },
      "server" : "logab-osx.local:27017"
      }
      > db.some.find().sort(

      {a:-1}

      ).explain()
      {
      "cursor" : "BtreeCursor a_0 reverse",
      "isMultiKey" : false,
      "n" : 1,
      "nscannedObjects" : 1,
      "nscanned" : 1,
      "nscannedObjectsAllPlans" : 1,
      "nscannedAllPlans" : 1,
      "scanAndOrder" : false,
      "indexOnly" : false,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "millis" : 0,
      "indexBounds" : {
      "a" : [
      [

      { "$maxElement" : 1 }

      ,

      { "$minElement" : 1 }

      ]
      ]
      },
      "server" : "logab-osx.local:27017"
      }
      >

            Assignee:
            Unassigned Unassigned
            Reporter:
            gabol Anton V. Volokhov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: