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.
Again 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.
It 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.
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/repairDatab...