3 ms·
All databases do not like to give back space they have allocated because allocating space is an expensive operation. You probably don't need to compact the db,
by darrenkopp 14y ago
All databases do not like to give back space they have allocated because allocating space is an expensive operation. You probably don't need to compact the db, unless you have a problem with file size (which in some scenarios I have had this issue).
There's nothing built in that I know of, but you can easily just make something that runs on a regular basis like a scheduled task or cron job that runs either compact command or repair database command.
http://docs.mongodb.org/manual/reference/command/compact/ http://docs.mongodb.org/manual/reference/command/compact/
http://docs.mongodb.org/manual/reference/command/repairDatabase/ http://docs.mongodb.org/manual/reference/command/repairDatab...
- fdr 14y agoIt is not only this: moving datums around in the database heap is expensive (invalidating caches, exacerbating thrashing) and touchy (index pointers, concurrency considerations). But debloating over time is an important property, so it's probably worth it to eventually get it right.
- arielweisberg 14y agoSpeak for your own databases. Mine does it just fine.
- darrenkopp 14y agoI didn't say they can't do it, they just don't like to.
- arielweisberg 14y agoAgain speak for your own databases. There are databases out there that plug each hole every time you delete a row AKA zero fragmentation. Only databases that fit their working set in memory have to resort to fragmentation to get reasonable performance. If the data set fits in memory there are other strategies.