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?
The default location for the MongoDB data directory is c:\data\db. So you need to create this folder using the Command Prompt.
MongoDB does store all its data on disk so that it can persist it during server restarts. However, it is primarily liking memory. It relies on the Operating System to schedule which bits of its database stay in memory, and which stays on disk.
By default, MongoDB stores its data into the memory to improve the performance. After reaching the criteria, MongoDB flushes data to the disk. Until then, the data is finally persisted.
In MongoDB, records are stored as documents in compressed BSON files. The documents can be retrieved directly in JSON format, which has many benefits: It is a natural form to store data. It is human-readable.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With