4

I have been using mongodb recently, and I have found out that it is taking a lot of space.

For example, in its db directory /var/lib/mongodb/, if I type "du -sh", then result turns out to be 417M. The thing is that there are only few entries in database, and I do not know how that can take up to 400M of space. Is it normal? or have I done something wrong?

user482594
  • 16,878
  • 21
  • 72
  • 108

2 Answers2

2

If space is an issue you can start up with a few options so the files aren't pre-allocated larger than your data. This will reduce performance, as then the data won't be contiguous on disk and will require allocation while you are insert/update data. Normally when data is deleted the space will not be released to the filesystem but the space in the allocated files will be reused by mongodb.

See this page for more information: http://www.mongodb.org/display/DOCS/Excessive+Disk+Space

Scott Hernandez
  • 7,452
  • 2
  • 34
  • 25
1

Databases typically expand space automatically but do not return it when no longer needed. This can happen during tests or running queries. Similarly if you have indexes or created aggregates with map-reduce they need to go somewhere next to "your" data.

Special tools must be run manually to reclaim the space. Checkout the repair database functionality.

Run it and see how many is still used after cleaning.

powlo
  • 2,538
  • 3
  • 28
  • 38
Peter Tillemans
  • 34,983
  • 11
  • 83
  • 114
  • I used that command for all the dbs that I have ( which I only have 2 ), and I still get 417M. The distribution is that admin.0 file takes 64MB, admin.1 takes 128MB, admin.ns takes 16MB, and one other db takes up the same amount of space. I guess (128+68+16)MB is the minimum space required for mongodb to efficiently running, even if I don't have many collections nor entries in each db. – user482594 Jun 04 '11 at 18:00
  • I checked on my machine where I have a couple of mongodb and I find indeen 64+128+16Mb. I also saw https://jira.mongodb.org/browse/SERVER-1636 where someone asks to make this configurable, but it seems no high priority. – Peter Tillemans Jun 04 '11 at 20:45