[SERVER-22370] compact does not run over indexes in WiredTiger Created: 29/Jan/16  Updated: 14/Apr/16  Resolved: 24/Feb/16

Status: Closed
Project: Core Server
Component/s: WiredTiger
Affects Version/s: 3.3.1
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Kyle Suarez
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-16856 Add ability to compact indexes for st... Closed
Related
is related to SERVER-22369 WT only reclaiming diskspace after 2n... Closed
Sprint: Integration F (02/01/16), Integration 10 (02/22/16), Integration 11 (03/14/16)
Participants:

 Description   

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.



 Comments   
Comment by Kyle Suarez [ 25/Feb/16 ]

A first attempt at this is looking pretty good – running Dan's script, it looks like the compaction is working:

table size: 1470464
index size: 528384
Remove all docs...
table size: 1470464
index size: 528384
Run compact...
table size: 12288
index size: 12288

Comment by Kyle Suarez [ 24/Feb/16 ]

Closing this as a duplicate of SERVER-16856, as that is a more general solution to this problem.

Generated at Thu Feb 08 04:00:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.