How to reduce MongoDB size after remove data

30 views
Skip to first unread message

Aroxo Senraj

unread,
Jun 13, 2018, 8:13:48 AM6/13/18
to mongodb-dev
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.

Wan Bachtiar

unread,
Jul 6, 2018, 1:59:06 AM7/6/18
to mongodb-dev

Hi Aroxo,

Questions related to the use of MongoDB (i.e. your question) are better sent to mongodb-user group. This group (mongodb-dev) is for discussion for/by/about developers/development/code of MongoDB.

Please post a new discussion on mongodb-user group with the following information:

  • MongoDB server version
  • Storage engine
  • How did you check the "MongoDB size" ? i.e. filesystem commands or mongo shell commands

Regards,
Wan.

Reply all
Reply to author
Forward
0 new messages