Reputation: 513
I'm running mongod with smallfiles option. Initially it created three files
These files I know and I know why MongoDb creates them. I started adding records in two collection in the database after some time, MongoDb created another data file .2 ---64 MB. When I looked at the size of two collection and index, I found that the total size is just about 30 MB which should have easily fit into the initial two files .0 and .1, but why MongoDB is creating the third file?
Here is size details
No other collection is the DB. As you can see the total storage size didn't exceed 30 MB. Why mongoDb created a third file when there are two data files already having size 16 + 32 MB?
Upvotes: 1
Views: 206
Reputation: 230286
It's because mongodb preallocates storage files. Suppose, you fill those two files up pretty quickly. You don't want to wait while a new file is allocated, because on some filesystems it may take time. Instead, mongodb arranges so that at each moment there is an empty file, ready to be written to.
Upvotes: 1