Does the $ne operator skip the index?

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Done
    • Priority: Minor - P4
    • None
    • Affects Version/s: 1.4.0
    • Component/s: Index Maintenance
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      When you use the $ne operator it seems to skip the index (unless I am reading the explain wrong) is that intentional?

      > db.quotations.find({noteworthy: {"$ne": false}}).limit(25).explain()
      {
      "cursor" : "BasicCursor",
      "indexBounds" : [ ],
      "nscanned" : 25,
      "nscannedObjects" : 25,
      "n" : 25,
      "millis" : 0,
      "oldPlan" :

      { "cursor" : "BasicCursor", "indexBounds" : [ ] }

      ,
      "allPlans" : [

      { "cursor" : "BasicCursor", "indexBounds" : [ ] }

      ]
      }

      versus me changing out {$ne: false} to true (I know it isn't equivalent)

      > db.quotations.find(

      {noteworthy: true}

      ).limit(25).explain()
      {
      "cursor" : "BtreeCursor noteworthy_1",
      "indexBounds" : [
      [

      { "noteworthy" : true }

      ,

      { "noteworthy" : true }

      ]
      ],
      "nscanned" : 5,
      "nscannedObjects" : 5,
      "n" : 5,
      "millis" : 0,
      "allPlans" : [
      {
      "cursor" : "BtreeCursor noteworthy_1",
      "indexBounds" : [
      [

      { "noteworthy" : true }

      ,

      { "noteworthy" : true }

      ]
      ]
      }
      ]
      }

            Assignee:
            Eliot Horowitz (Inactive)
            Reporter:
            Ben Wyrosdick
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: