Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-7337

count will now respect a hint with no query predicate

    XMLWordPrintableJSON

Details

    Description

      We fixed SERVER-22041, which is a backwards breaking change. This should make it into the compatibility notes.

      Previous behavior:

      > db.foo.drop()
      true
      > db.foo.ensureIndex({a: 1}, {sparse: true})
      {
      	"createdCollectionAutomatically" : true,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      > db.foo.insert({})
      WriteResult({ "nInserted" : 1 })
      > db.foo.find().hint({a: 1}).count()
      1  // Unexpected: should return 0 instead.
      

      New behavior:

      > db.foo.drop()
      true
      > db.foo.ensureIndex({a: 1}, {sparse: true})
      {
      	"createdCollectionAutomatically" : true,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      > db.foo.insert({})
      WriteResult({ "nInserted" : 1 })
      > db.foo.find().hint({a: 1}).count()
      0  // Weird, but this is consistent with how the find command respects hints.
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              1 year, 14 weeks, 1 day ago