How to reduce MongoDB size after remove data

26 views
Skip to first unread message

Aroxo Senraj

unread,
Jun 13, 2018, 6:17:04 PM6/13/18
to mongodb-user
1. First I have checked MongoDB Size 36GB
2. I have removed few tables data
3. Again I have checked MongoDB Size (36GB) not reduced. After I have searched google and solution. 

I have tried few below methods and take more time, slow my application (hang)
Method 1: db.repairDatabase
Method 2:
db.getMongo().getDBNames().forEach(function(dbName) {
    if ("local" != dbName && "admin" != dbName && "system" != dbName) {
        var subject = db.getSiblingDB(dbName);
        subject.getCollectionNames().forEach(function (collectionName) {
            print('Compacting: ' +dbName + " - " + collectionName);
            subject.runCommand({ compact: collectionName });
        });
    }
});

So, I need better solution. If any one know about this kindly let me know.

Stéphane Tremblay

unread,
Jun 14, 2018, 9:33:01 AM6/14/18
to mongodb-user
Xx
Reply all
Reply to author
Forward
0 new messages