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

Please provide a way to use $hint for Update/FindAndModify, and/or fix the Query Optimizer

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • None
    • None
    • Querying
    • None
    • Fully Compatible
    • Windows

    Description

      We're having an issue where a FindAndModify in our code, in some of our environments/servers, decides to use an index that fails horribly (i.e. is sparse, when we're querying for nulls), and would like a way to force it to use a correct index. We're open to using an Update instead, if it would mean a faster turn-around on this issue.

      Our current example:

      SECONDARY> db.version()
      2.0.3

      SECONDARY> db.ourcollection.getIndexes()
      [
      {
      "v" : 1,
      "key" :

      { "_id" : 1 }

      ,
      "ns" : "ourdb.ourcollection",
      "name" : "id"
      },
      {
      "v" : 1,
      "key" :

      { "StartedOn" : -1 }

      ,
      "ns" : "ourdb.ourcollection",
      "name" : "StartedOn_-1",
      "background" : true,
      "sparse" : true
      }
      ]

      SECONDARY> db.ourcollection.find(

      { "_id" : new BinData(3,"L9UXPwbYdEiSQ68DG7A1iQ=="), "StartedOn" : null }

      ).explain()
      {
      "cursor" : "BtreeCursor StartedOn_-1",
      "nscanned" : 30,
      "nscannedObjects" : 30,
      "n" : 0,
      "millis" : 0,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "isMultiKey" : false,
      "indexOnly" : false,
      "indexBounds" :

      { "StartedOn" : [ [ null, null ] ] }

      }

      SECONDARY> db.ourcollection.find(

      { "_id" : new BinData(3,"L9UXPwbYdEiSQ68DG7A1iQ==") }

      ,

      { _id: 1, StartedOn: 1 }

      ).toArray()
      [

      { _id: BinData(3,"L9UXPwbYdEiSQ68DG7A1iQ==") }

      ]

      SECONDARY> db.ourcollection.find(

      { "_id" : new BinData(3,"L9UXPwbYdEiSQ68DG7A1iQ=="), "StartedOn" : null }

      ).toArray()
      [ ]

      Attachments

        Issue Links

          Activity

            People

              aaron Aaron Staple
              alyman Alex Lyman
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: