Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-22370

compact does not run over indexes in WiredTiger

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.3.1
    • Component/s: WiredTiger
    • None
    • Integration F (02/01/16), Integration 10 (02/22/16), Integration 11 (03/14/16)
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      While testing SERVER-21833, I noticed that indexes are not compacted, which means we leave around all the space allocated for them even after removing all the data. We should run the WT compact command on all indexes as well as on the collection.

      Test case:

      db.a.drop();
      for(i=0;i<60000;i++) { db.a.insert({x:i, y:"asdfasdfasdfasdfasdfasdfasdfasdfasdf"}); }
      db.adminCommand('fsync'); // force checkpoint
      var collectionSize = db.a.stats().storageSize;
      var indexSize = db.a.stats().indexSizes._id_;
      print("table size: " + collectionSize);
      print("index size: " + indexSize);
      
      print("Remove all docs...");
      db.a.remove({});
      db.adminCommand('fsync'); // force checkpoint
      print("table size: " + db.a.stats().storageSize);
      print("index size: " + db.a.stats().indexSizes._id_);
      
      print("Run compact...");
      db.a.runCommand('compact');
      print("table size: " + db.a.stats().storageSize);
      print("index size: " + db.a.stats().indexSizes._id_);
      db.adminCommand('fsync'); // force checkpoint
      
      assert.gt(collectionSize, db.a.stats().storageSize, "collection size should be smaller after compact");
      assert.gt(indexSize, db.a.stats().indexSizes._id_, "index size should be smaller after compact");
      

      NB: WT does not attempt compaction on collections < 1MB. See SERVER-22369.

            Assignee:
            kyle.suarez@mongodb.com Kyle Suarez (Inactive)
            Reporter:
            dan@mongodb.com Daniel Pasette (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: