​How to ​free space used by mongodb after deletion of collections

  • fennng 

I have a free mongodb instance with MLab.

And I am reaching the max limit of 500M for the free tier.

So that I would like to release some space. I delete one of the biggest
collection and followed the following instruction on the Mlab doc site. But
it didn’t work. No space has been released.

Then I tried to use mongo shell to do the job. The command runs well, but
it didn’t do any thing. Then I tried the compact command… then It stuck.

Oh, shit, then I realize I just missing the close bracket )
keep going

add force

but still nothing changed.

Then I found this article.


And realize that my mongodb instance on Mlab is MMAPv1, it will not release
space by using compact command.

But in this case, the repairDatabase command should still work. Then I
found this article.


That may explains.

The Size 496M come from this calculation


Because My data is more than 240M (2^4+2^5+2^6+2^7) so that Mlab allocate
another space of 2^8 (256M), so that it will be still 496M

The datasize + indexSize of my mongodb is around 290M, which is bigger than

So, I shouldn’t worry about it and stop wasting my time to try to reduce
the file size.

As long as my datasize + indexSize doesn’t go beyong 496M, my database will
be up and running.



您的电子邮箱地址不会被公开。 必填项已用*标注