How to reduce MongoDB storage space after deleting large amount of data?

MongoDBDatabaseBig Data Analytics

To reduce MongoDB storage space after deleting a large amount of data, you need to use repairDatabase(). Let’s say we are using the database “test”. Following is the query to get to the current database

> db;

This will produce the following output

Test

After deleting large amount of data, this is how you can reduce the storage space of MongoDB

> db.repairDatabase()

This will produce the following output

{ "ok" : 1 }

Here is the screenshot after we implement the above query. This will reduce the storage space:

raja
Updated on 30-Jul-2019 22:30:25

Advertisements