How big is your MongoDB?

Update 11/10/14: The next blog post in this series is on managing disk space in MongoDB.

As your MongoDB grows in size, information from the db.stats() diagnostic command (or the database "Stats" tab in our management portal) becomes increasingly helpful for evaluating hardware requirements.

We frequently get questions about the dataSize, storageSize and fileSize metrics, so we want to help developers better understand how MongoDB storage works and what these particular metrics mean.

MongoDB storage structure basics

First, we'll go over the basics of how MongoDB stores your data.

Data files

Every MongoDB instance consists of a namespace file,  journal files and data files. For our discussion, we'll only be focusing on data files, since that is where all of the data and indexes for your database reside.

Data files store BSON documents, indexes, and MongoDB-generated metadata in structures called extents. Each data file is made up of multiple extents.


Extents are logical containers within data files used to store documents and indexes.

Photo of data files and extents

The above diagram illustrates the relationship between data files and extents. Note:

  • Data and indexes are each contained in their own sets of extents; no extent will ever contain content for more than one collection
  • Data and indexes are never contained within the same extent
  • The data and indexes for a collection will usually span multiple extents
  • When a new extent is needed, MongoDB will attempt to use available space within current data files. If space cannot be found MongoDB will create new data files.

Metrics from db.stats()

Now that we understand the basics of how MongoDB storage is organized, we can explore metrics commonly examined with db.stats(): dataSize, storageSize and fileSize.


Picture of MongoDB dbStats dataSize

The dataSize metric is the sum of the sizes (in bytes) of all the documents and padding stored in the database.

While dataSize does decrease when you delete documents, dataSize does not decrease when documents shrink because the space used by the original document has already been allocated (to that particular document) and cannot be used by other documents.

Alternatively, if a user updates a document with more data, dataSize will remain the same as long as the new document fits within its originally padded pre-allocated space.


Photo of MongoDB dbStats storageSize

The storageSize metric is equal to the size (in bytes) of all the data extents in the database. This number is larger than dataSize because it includes yet-unused space (in data extents) and space vacated by deleted or moved documents within extents.

The storageSize does not decrease as you remove or shrink documents.


Photo of MongoDB dbStats fileSize

The fileSize metric is equal to the size (in bytes) of all the data extents, index extents and yet-unused space (in data files) in the database. This metric represents the storage footprint of your database on disk. fileSize is larger than storageSize because it includes index extents and yet-unused space in data files.

While fileSize does decrease when you delete a database, fileSize does not decrease as you remove collections, documents or indexes.

What now?

That's it! The next time someone asks you how big your database is you know what to tell them.

, , , , , ,

34 Responses to How big is your MongoDB?

  1. lyon 2014/02/06 at 8:52 pm #

    Great post!

  2. tarunjaiswal 2014/04/10 at 1:43 am #

    Great explanation, Chris!

  3. Raji 2014/07/14 at 6:48 pm #

    For 2 sample sizes of collections with data sizes of 1K + 120 bytes of Index and 64K + 256 bytes of Index , what will be the storage size and file size be? What is the best way to calculate these?

  4. Kajsa Anderson 2015/03/24 at 7:36 pm #

    So if I want to see how much space has been allocated but is not used, do I want fileSize – dataSize – indexSize?

  5. André Badenhorst 2015/10/01 at 11:41 pm #

    Just a quick question. Which of the dataSize, storageSize or fileSize is considered for the 500MB limitation on the MongoLab Sandbox option?

  6. Chris Chang 2015/10/01 at 11:54 pm #

    file size

  7. André Badenhorst 2015/10/02 at 1:53 am #

    Amazingly quick response, thank you! It appears, with the creation of the MongoLab Sandbox db, that the file size is already set to 580MB, probably reserved and limited to that size. So I guess the storageSize will now be the one to watch.

  8. Nico Vazquez 2015/10/07 at 8:29 am #

    The game is growing and 2.2 million users who installed the app today we only have 50,000 active users who play daily basis. The other users can not connect more than three months ago and no longer regard them as active users. But even if they are not active, these users could connect at any time and must be able to recover the last user session state automatically becoming an active user.

    Today we are using a server MongoDB replica set 7 GB of RAM and this generates a very large for the number of active users has cost the game.

    They want to reduce the cost of database and run the game properly and with the same response times with the current server.

    We know that if we move the base with the current characteristics at a lower cost server, the response times of queries increments due to the number of indexes and records that have the same.

    Sorry for the wording but I’m Spanish. Any recommendation?

  9. Junwei Zhuge 2016/03/15 at 11:20 am #

    I think this problem is what most apps are facing or will be facing. Why not remove the data of users who keep inactive for like more than 6 months? Choose an appropriate time threshold, compared the profit from those users with the cost of the server.

  10. Vivek 2016/08/01 at 8:49 pm #

    In case of the WiredTiger in MongoDB versions 3.x, the dataSize in many cases comes to be greater than the StorageSize, how is that possible?

  11. mca 2017/04/01 at 2:31 pm #

    98817 215467Quite intriguing information !Perfect just what I was looking for! 986213

  12. Best News Website in World 2017/04/06 at 7:20 pm #

    377603 7631Your writing is fine and gives food for thought. I hope that Ill have a lot more time to read your articles . Regards. I wish you which you regularly publish new texts and invite you to greet me 900410

  13. Best Best Online News in the World 2017/04/07 at 12:44 am #

    81384 894270An intriguing discussion will probably be worth comment. I believe which you just write significantly a lot more about this subject, it may well become a taboo topic but typically consumers are inadequate to communicate in on such topics. To yet another. Cheers 366267

  14. Best Best Online News in the World 2017/04/07 at 5:31 am #

    701227 793520This web site can be a walk-through its the details you wanted concerning this and didnt know who to ask. Glimpse here, and you will undoubtedly discover it. 617331

  15. Best Best Online News in the World 2017/04/07 at 1:34 pm #

    838523 441052Your writing is fine and gives food for thought. I hope that Ill have more time to read your articles . Regards. I wish you that you frequently publish new texts and invite you to greet me 971316

  16. Best Best Online News in the World 2017/04/07 at 1:59 pm #

    59678 333537A thoughtful insight and ideas I will use on my blog. Youve obviously spent a lot of time on this. Thank you! 7955

  17. Best Best Online News in the World 2017/04/08 at 4:22 am #

    395389 705052An fascinating discussion may possibly be valued at comment. I do believe which you just write read a lot more about this subject, it may well not often be a taboo topic but normally persons are too couple of to dicuss on such topics. To a higher. Cheers 449237

  18. Best Best Online News in the World 2017/04/08 at 6:45 am #

    288660 641916Outstanding read, I just passed this onto a friend who was doing some research on that. And he really bought me lunch since I discovered it for him smile So let me rephrase that: Thank you for lunch! 471049

  19. Best Best Online News in the World 2017/04/08 at 9:58 am #

    824958 808448Lovely sharp post. Never considered that it was that easy. Praises to you! 486133

  20. Best Best Online News in the World 2017/04/08 at 6:36 pm #

    122366 4071Right after study several the websites together with your web site now, and that i genuinely appreciate your method of blogging. I bookmarked it to my bookmark web site list and are checking back soon. Pls have a appear at my internet page likewise and let me know should you agree. 271738

  21. GVK BIO 2017/04/08 at 6:37 pm #

    943883 964920very good post. Neer knew this, thanks for letting me know. 416828

  22. GVK Biosciences 2017/04/08 at 11:35 pm #

    297290 191553Most heavy duty trailer hitches are created making use of cutting edge computer aided models and fatigue stress testing to ensure optimal strength. Share new discoveries together with your child and maintain your child safe by purchasing the correct style for your lifestyle by following the Perfect Stroller Buyers Guideline. 944293

  23. GVK Biosciences 2017/04/09 at 2:04 am #

    530142 867884 I discovered your blog website on google and check a couple of of your early posts. Continue to keep up the extremely great operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading much more from you later on! 831170

  24. VideoJelly 2017/04/11 at 5:08 pm #

    797245 826427Following I initially commented I clicked the -Notify me when new feedback are added- checkbox and now each time a remark is added I get four emails with the same comment. Is there any method youll be able to take away me from that service? Thanks! 949770

  25. Switch Energy Supplier 2017/04/21 at 10:47 am #

    193170 641018Simply a smiling visitor here to share the love (:, btw outstanding design . “Audacity, more audacity and always audacity.” by Georges Jacques Danton. 859534

  26. Best Online News 2017/04/22 at 11:30 am #

    604361 191583I really love the theme on your website, I run a web site , and i would adore to use this theme. Is it a free style, or is it custom? 989103

  27. faux bracelet 3 ors cartier 2017/05/15 at 5:24 am #

    Hello i am kavin, its my first time to commenting anyplace, when i read this article i thought i could also make comment due to this good article.|
    faux bracelet 3 ors cartier

  28. bracelet cartier or blanc copie 2017/05/15 at 5:24 am #

    I like the valuable information you provide in your articles. I’ll bookmark your blog and check again here frequently. I am quite sure I’ll learn a lot of new stuff right here! Best of luck for the next!|
    bracelet cartier or blanc copie

  29. There once was a time when surgeons used to operate without washing their hands first, and we once put depressed people in asylums. Hopefully, we learn from our mistakes, which is what all the “new rules” are about.
    hermes birkin 35 bags replica for women

  30. Definitely believe that that you said. Your favorite reason appeared to be at the web the simplest factor to understand of. I say to you, I certainly get irked at the same time as other folks think about issues that they just do not recognize about. You managed to hit the nail upon the highest and also defined out the whole thing with no need side effect , people can take a signal. Will probably be again to get more. Thanks|
    bague or blanc cartier diamants imitation

  31. falso anello diamanti cartier 2017/05/18 at 7:17 am #

    As a writer I have run up against a limited of Googles possible shootdowns. Mars – chanics, warriors, army, soldier, chemist and druggists, carpenters, bankers and insurance agents.Lavish climax, pointless to say, software, this type of go walking upright vacuum cleaner, the main automatic robot are classified as the violin with regards to degree shown incredible rubbing guitar strings, ribbon proficiencies. Each and every people are entertained by the teams of this association.However, other specialists have challenged the iconoclastic report and contend that mammography is lifesaving.Browsing the , one usually definitely find sites that have such direct live feed. Venus – musicians, artists, tors and tresses and all lovers of art. Why not opt for a systematic approh!The book brings out systematic weight loss suggestions countering the popular values like resorting on caloric cra food items, exercising a couple of hours eh day, slim pl much more. The southern most part of Algarve Portugal has a rich history and culture and if you just wander around you discover traces of the past even today. These stores have wide selections of handcrafted ballroom and even Latin dance oes from overseas oe capitals.
    falso anello diamanti cartier


  1. Managing disk space in MongoDB | MongoLab: MongoDB-as-Service - 2014/01/29

    […] our previous post on MongoDB storage structure and dbStats metrics, we covered how MongoDB stores data and the differences between the dataSize, storageSize and […]

  2. Mongolab about disk usage and data structure of MongoDB | Data story - 2014/02/10

    […] How big is your MongoDB? […]

  3. MongoDB. Repara tus bases de datos | Rekkeb's Blog - 2014/09/15

    […] MongoLab | How Big is Your MongoDB? […]

Leave a Reply