Skip to content

Instantly share code, notes, and snippets.

@gregorycoleman
Created January 21, 2018 06:27
Show Gist options
  • Save gregorycoleman/c500cea0e704503b2c4d6af41a47f949 to your computer and use it in GitHub Desktop.
Save gregorycoleman/c500cea0e704503b2c4d6af41a47f949 to your computer and use it in GitHub Desktop.
wget -qO- http://goo.gl/????? | mongo --quiet <db-name>
#You can also output all your indexes together with their size:
rs.slaveOk();
db.getCollectionNames().forEach(function(coll) {
print("db." + coll + ".ensureIndex(" + tojson(index.key) + ")");
db.[coll].stats().indexSizes
});
rs.slaveOk();
db.getCollectionNames().forEach(function(coll) {
db[coll].getIndexes().forEach(function(index) {
if ("_id_" !== index.name) {
print("db." + coll + ".ensureIndex(" + tojson(index.key) + ")");
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment