I have a database in MongoDB, called dump. Currently, it reached 6GB in my server. I decided to delete 90% of data in this database to reduce the disk space it occupied. But after doing that its size is still 6GB, while the true storage size is only 250MB.
I guess this is the design of MongoDB? Is there any convinient way to reduce its size? Thank in advance.
Try (source):
$ mongo mydb
> db.repairDatabase()
To compress the data files, you can run either start up MongoDB with mongod --repair
, or connect to the database through the shell and run db.repairDatabase()
.
There's also a new compact command scheduled for v1.9 that will do in-place compaction.
精彩评论