On Saturday, 17 October 2015 09:35:44 UTC+11, jonathan wrote:
I’m using mongodb 3.0.6 and WiredTiger+zlib. the os is ubuntu 12.04, and i installed off the official package.
My collection was ~30GB of data. After some analysis, I decided to remove 10% of records as they accounted for 1/3 of disk space. Instead of just deleting them - to be safe - I copied them to a new collection.
Hi Jonathan,
Disk usage behaviour varies by storage engine. In the case of WiredTiger the documents have been marked as deleted with the space available for reuse. You can use the compact command to rewrite the collection and release unused disk space.
Note to MMAP users who might find this post: the compact command does not release free space on MMAPv1. Make sure you check the MongoDB documentation for any notes relevant to your configured storage engine.
I took 11GB out so I could get the DB down to around 20GB… and now I have a 40GB db.
Does the 40GB refer to the total of all data, or does it appear that your original collection grow from 30GB to 40GB?
If you started with ~30GB of data files and copied ~11GB to another collection, it sounds like the expected total of all files would be around 40GB.
On Saturday, 17 October 2015 13:49:29 UTC+11, A. Jalil @AJ wrote:
I would check if you have powerof2sizes enabled.. I’ve read somewhere that it does increase the storage size, but on the other hand it increases performance as well..
The powerOf2Sizes allocation strategy is specific to the MMAP storage engine, and is the default allocation strategy for MMAP in MongoDB 2.6+. MMAP supports in-place document updates so the additional storage allocation minimizes unnecessary index updates and moves due to document growth. A document that outgrows its storage allocation in MMAP will get moved to a larger storage allocation, which also requires updating all the index entries to point to the new document location.
Regards,
Stephen
Does the 40GB refer to the total of all data, or does it appear that your original collection grow from 30GB to 40GB?
If you started with ~30GB of data files and copied ~11GB to another collection, it sounds like the expected total of all files would be around 40GB.
On Sunday, 18 October 2015 05:42:20 UTC+11, A. Jalil @AJ wrote:
In one of your responses at https://groups.google.com/forum/#!topic/mongodb-user/82ORyR5hbYc you said I can use <resync> command to reclaim space, now I see the command <compact> mentioned on this thread - I was wondering if these commands do different things and whether I should also try <compact> to reclaim free space in my case..
Hi AJ,
As I noted earlier in this thread, the behaviour of the compact command is storage engine specific. With MMAP (the default storage engine in MongoDB 3.0 and earlier), a compact command will rewrite the collection but does not release any preallocated space for MMAP: http://docs.mongodb.org/v3.0/reference/command/compact/#disk-space. The original question in this thread was asking about WiredTiger on a standalone node.
Completely rebuilding data files via repair or resync is a more general way to reclaim unused space. I would only recommend the repair command for a standalone node.
If a node is part of a replica set deployment, the recommended approach to release unused space without downtime is a rolling resync (re-syncing one secondary at a time until finally you step down and re-sync the former primary).
Regard,
Stephen