开发者

Compact command not freeing up space in MongoDB 2.0

I just installed MongoDB 2.0 and tried to run the compact command instead of the repair command in earlier versions. My database is empty at the moment, meaning there is only one collection with 0 entries and the two system collections (indices, users). Currently the db takes about 4 GB of space on the harddisk. The db is used as a temp queue with all items being removes after they have been processed开发者_Go百科.

I tried to run the following in the mongo shell.

use mydb
db.theOnlyCollection.runCommand("compact")

It returns with

ok: 1

But still the same space is taken on the harddisk. I tried to compact the system collections as well, but this did not work.

When I run the normal repair command

db.repairDatabase()

the database is compacted and only takes 400 MB.

Anyone has an idea why the compact command is not working?

Thanks a lot for your help.

Best

Alex


Collection compaction is not supposed to decrease the size of data files. Main point is to defragment collection and index data - combine unused space gaps into continuous space allowing new data to be stored there. Moreover it may actually increase the size of data files:

Compaction may increase the total size of your data files by up to 2GB. Even in this case, total collection storage space will decrease.

http://www.mongodb.org/display/DOCS/compact+Command#compactCommand-Effectsofacompaction

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜