Contents
Does MongoDB compress data by default?
Compression. With WiredTiger, MongoDB supports compression for all collections and indexes. Compression minimizes storage use at the expense of additional CPU. By default, WiredTiger uses block compression with the snappy compression library for all collections and prefix compression for all indexes.
How does MongoDB compress data?
MongoDB with WiredTiger engine can compress data collections, indexes and journals. By default, WiredTiger uses snappy compression. The zlib compressor is also available. Generally, compression will consume more CPU cycles but it will lower disk space utilization.
How do I compact a collection in MongoDB?
Compacting one or more databases For a single-node MongoDB deployment, you can use the db. repairDatabase() command to compact all the collections in the database. This operation rewrites all the data and indexes for each collection in the database from scratch and thereby compacts and defragments the entire database.
What does MongoDB repair do?
Starting in MongoDB 4.4, for the WiredTiger storage engine, mongod –repair : Rebuilds all indexes for collections with one or more inconsistent indexes. Discards corrupt data. Creates empty/stub files for missing data/metadata files.
When to use the COMPACT command in MongoDB?
Before v4.4, compact blocked all operations for the database it was compacting, including MongoDB CRUD Operations, and was therefore recommended for use only during scheduled maintenance periods. Starting in v4.4, the compact command is appropriate for use at any time.
When does compact block CRUD operations in MongoDB?
Starting in v4.4, compact does not block MongoDB CRUD Operations on the database it is compacting. Optional. A user-provided comment to attach to this command.
How much free disk space do I need for MongoDB?
However, keep in ming that it does not release space to the operating system. The operation is still useful to defragment and create more contiguous space for reuse by MongoDB, but it’s of no use when the free disk space is very low. An additional disk space up to 2GB is required during the compaction operation.
What happens when data is deleted from MongoDB?
In the event a large chunk of data is deleted from a collection and the collection never uses the deleted space for new documents, this space needs to be returned to the operating system so that it can be used by your other databases or collections.