-
Type:
Improvement
-
Resolution: Duplicate
-
Priority:
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.
- is duplicated by
-
SERVER-16856 Add ability to compact indexes for storageEngines where that is meaningful
-
- Closed
-
- is related to
-
SERVER-22369 WT only reclaiming diskspace after 2nd compact
-
- Closed
-