[SERVER-6520] Ironically Compaction makes our collection 10GB bigger ! Created: 19/Jul/12  Updated: 15/Aug/12  Resolved: 19/Jul/12

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 2.0.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Stone, Gao Assignee: Eric Milkie
Resolution: Done Votes: 0
Labels: storage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ubuntu 10.04 mongodb 2.0.3


Operating System: Linux
Participants:

 Description   

This was crazy and made me even think what's the meaning of "Compaction" for mongodb ?

> show dbs
db0 35.9365234375GB
local 10.1982421875GB
test (empty)
> use db0
switched to db db0
> db.entries.count()
51927379
> db.entries.runCommand( "compact" )

{ "ok" : 1 }

> show dbs
db0 45.931640625GB
local 10.1982421875GB
test (empty)



 Comments   
Comment by Stone, Gao [ 19/Jul/12 ]

Got it. Thanks for your quick response!

Comment by Eric Milkie [ 19/Jul/12 ]

The docs at http://www.mongodb.org/display/DOCS/Excessive+Disk+Space#ExcessiveDiskSpace-RecoveringDeletedSpace
explain why this occurs. The compact command only defragments and compacts data records within the data files. It doesn't shrink the data files, and in fact it can grow them as it needs work space to do the defragmentation.
The current way to reduce the size of the data files is to use repair, which copies all the records to new temporary data files and then swaps them with the current data files.

Generated at Thu Feb 08 03:11:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.