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

Real document size in collection

    XMLWordPrintable

    Details

    • Type: Question
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Diagnostics, Shell, Tools
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            stennie Stennie Steneker
            Reporter:
            botajzorek Jan Botorek
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: