Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDb : Avoid excessive disk space

Tags:

mongodb

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!!!

like image 287
azhar_salati Avatar asked Aug 22 '11 12:08

azhar_salati


1 Answers

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.

like image 126
Teun D Avatar answered Oct 01 '22 13:10

Teun D