Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am having some troubles with MongoDB and space usage. In particular, I once used to have a large collection of about 600 million records totaling 110+ GB on disk. Recently I decided to drop it because the data was outdated, to do so I dropped the collection through rockmongo's web interface. Accordingly, rockmongo doesn't show me the collection anymore, however my disk usage hasn't changed at all.

Is there any clean operation which I am not aware of, which must be run in order to synchronize the database with database files on disk?

I have tried to perform a "repair" but the system complains that there's not enough space on disk ... that's because it is all used by MongoDB.

share|improve this question

migrated from stackoverflow.com May 15 '11 at 7:16

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 9 down vote accepted

As with most database systems, the database files does not shrink when you delete data, the data is just removed/marked as deleted, and the space is reused.

You'll need to run db.repairDatabase() to compact space as noted here

share|improve this answer
    
Hard disk space was too low to do that. However I solved this way: mongodump, oldDatabase.dropDatabase(), mongorestore --db newDatabase dump/oldDatabase. –  tunnuz May 12 '11 at 13:43

As of version 2.0, the compact command is now available. http://www.mongodb.org/display/DOCS/compact+Command

share|improve this answer
    
The compact command doesn't actually reduce space. It will typically take up more space. Think of it as a defrag. It condenses where in the used space the data resides, but still retains the original space it had. –  user125280 Jun 20 '12 at 0:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.