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

Real document size in collection

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Diagnostics, Shell, Tools
    • None

      Hello, I am not able to find out the real size of document stored in mongo collections. I googled, that document size may be obtained by two methods:
      Object.bsonsize - some javascript method that should return a size in bytes
      db.collection.stats() - where there is a line 'avgObjSize' that produce some "aggregated"(average) size view on the data. It simply represents average size of single document.

      I have a really simple document with this structure:
      {
      test: "test",
      ids: [id1, id2, id3..... id500000]
      }
      each id is constructed by 10 characters.

      By simle computation, the overall size should be more than 5 MB.
      But when I initiate the 'Object.bsonsize' command, it returns: 499.
      Stats command returns 'size' = 10747888.

      I am really confused. Is there any way how to reliable find out size of the particular document? Are my steps performed so far absolutely wrong?

      Thank you for your support, any help will be appreciated.

            Assignee:
            stephen.steneker@mongodb.com Stennie Steneker (Inactive)
            Reporter:
            botajzorek Jan Botorek
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: