I am having a database which has been allocated a space of 85GB. I got this size using the show dbs command. But when I use the db.stats(), i get the storage size as 63GB. After going through the docs I found dat mongo db allocates a size to the db that is created and then the actual data is filled.
Why does mongo does this preallocation and is there a way I can avoid this preallocation ?
If Yes, will it be a good idea to do it or it is going to affect from performance point of view ?
Thanks!!!
Details can be found here: http://www.mongodb.org/display/DOCS/Excessive+Disk+Space
Now to your case. I think that the current size of your datafiles cannot be caused by preallocation alone. The maximum size of allocated data files is 2G. Maybe you once stored much more data than today? The link above also shows how to reclaim this data if you're sure you will not need it soon anyway. This will require a lot of disk space during the process, so you must give this some planning.
Disabling preallocation will indeed have perfomance impact. When you do many inserts, the process would regularly have to wait to create a new file.
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