2

I'm new to MongoDB (using mongo 3.05)- and was seeing a behavior I didn't quite understand or could find an answer to - When I show the DBs in the mongo environment = I see a list of the databases and they all take some fixed sizes - some of the are about 72MB, and some are about 210MB - that's it.

When I export the databases for backup - I have total of about 40MB for all databases.

I would like to understand this better, is someone familiar with this behavior?Thanks!

1 Answer 1

5

From FAQ: MongoDB Storage:

MongoDB preallocates its data files to avoid filesystem fragmentation, and because of this, the size of these files do not necessarily reflect the size of your data.

The database sizes you are seeing when you execute show dbs reflect the sizes of corresponding data files on your hard drive. When you create a new database, a new data file will be allocated, even if there's no actual data yet.

Naturally, when you back up your data, only the actual data gets written to the backup file. Preallocated database files have empty space in them, which is why they are generally larger than backup files.

Your Answer

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

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