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

Allowed to build {<field>:0} index

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial - P5
    • Resolution: Duplicate
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: Indexing
    • Labels:
    • Environment:
      osx 10.8, ubuntu 12.10, ubuntu 10.10
    • Operating System:
      ALL
    • Steps To Reproduce:
      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()

      Description

      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"
      }
      >

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: