MongoDB data remove - reclaim diskspace

griffin picture griffin · Apr 1, 2011 · Viewed 36.8k times · Source

Possible Duplicate:
Auto compact the deleted space in mongodb?

My understanding is that on delete operations MongoDB won't free up the disk space but would reuse it as needed.

  1. Is that correct?
  2. If not, would I have run a repair command?
  3. Could the repair be run on a live mongo instance?

Answer

Andrew Orsich picture Andrew Orsich · Apr 1, 2011
  1. Yes it is correct.
  2. No, better to give mongodb as much disk space as possible( if mongodb can allocate more space than less disk fragmentation you will have, in additional allocating space is expensive operation). But if you wish you can run db.repairDatabase() from mongodb shell to shrink database size.
  3. Yes you can run repairDatabase on live mongodb instance ( better to run it in none peak hours)