Skip to content

Instantly share code, notes, and snippets.

@gatesvp
Created December 30, 2010 17:59
Show Gist options
  • Select an option

  • Save gatesvp/760056 to your computer and use it in GitHub Desktop.

Select an option

Save gatesvp/760056 to your computer and use it in GitHub Desktop.
Stolen from here: http://stackoverflow.com/questions/4555938/ Well done.
// Get a the current collection size.
var storage = db.foo.storageSize();
var total = db.foo.totalSize();
print('Storage Size: ' + tojson(storage));
print('TotalSize: ' + tojson(total));
print('-----------------------');
print('Running db.repairDatabase()');
print('-----------------------');
// Run repair
db.repairDatabase()
// Get new collection sizes.
var storage_a = db.foo.storageSize();
var total_a = db.foo.totalSize();
print('Storage Size: ' + tojson(storage_a));
print('TotalSize: ' + tojson(total_a));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment