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

Shell doesn't re-save retrieved integers in an array as integers (converted to 64-bit float)

    • ALL

      # Insert three integers
      db.test.insert({ nums: [NumberInt(1), NumberInt(2), NumberInt(3)] })
      
      # Check the size
      db.test.stats()
      {
      	"ns" : "mydb.test",
      	"count" : 1,
      	"size" : 56,
      	"avgObjSize" : 56,
      	"storageSize" : 4096,
      	"numExtents" : 1,
      	"nindexes" : 1,
      	"lastExtentSize" : 4096,
      	"paddingFactor" : 1,
      	"flags" : 1,
      	"totalIndexSize" : 8176,
      	"indexSizes" : {
      		"_id_" : 8176
      	},
      	"ok" : 1
      }
      
      # Retrieve and save the doc back to the database
      > doc = db.test.findOne()
      > db.test.save(doc)
      
      # Size should be the same if array elements saved as ints.
      > db.test.stats()
      {
      	"ns" : "mydb.test",
      	"count" : 1,
      	"size" : 116,
      	"avgObjSize" : 116,
      	"storageSize" : 4096,
      	"numExtents" : 1,
      	"nindexes" : 1,
      	"lastExtentSize" : 4096,
      	"paddingFactor" : 1.59,
      	"flags" : 1,
      	"totalIndexSize" : 8176,
      	"indexSizes" : {
      		"_id_" : 8176
      	},
      	"ok" : 1
      }
      

      The size increases because they are being re-saved as 64-bit floats and it increases by more than just 6 bytes because of padding factor.

            Assignee:
            backlog-server-platform DO NOT USE - Backlog - Platform Team
            Reporter:
            tyler@10gen.com Tyler Brock
            Votes:
            7 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated: