76

I know that MongoDB accepts and retrieves records as JSON/BSON objects, but how does it actually store these files on disk? Are they stored as a collection of individual *.json files or as one large file? I have a hunch as to the latter, since the MongoDB docs state that it works best on systems with ext4/xfs, which are better at handling large files. Can anyone confirm?

4 Answers 4

43

A given mongo database is broken up into a series of BSON files on disk, with increasing size up to 2GB. BSON is its own format, built specifically for MongoDB.

These slides should answer all of your questions:

http://www.slideshare.net/mdirolf/inside-mongodb-the-internals-of-an-opensource-database

0
24

MongoDB stores the data on the disk as BSON in your data path directory, which is usually /data/db. There should be two files per collection there, collection.0, which stores the data (and that integer is then incremented as needs be) and collection.ns which stores the namespacing metadata for the collection.

1
  • 1
    this answer is better than the chosen one. Apr 4, 2022 at 16:26
4

Detailed documentation of the BSON format can be found here: http://bsonspec.org/

3

Up to mongodb 3.0 http://blog.mongolab.com/2014/01/how-big-is-your-mongodb/ If you turn on wiredtiger storage engine in MongoDB 3.0 it will use wiredtiger storage model http://docs.mongodb.org/v3.0/core/storage/#storage-wiredtiger

1

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.