Last active
July 19, 2016 13:07
-
-
Save mping/a9fa6a187f1857dd8a54dd2e6729a460 to your computer and use it in GitHub Desktop.
mongodb common ops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// drop all non-system colls | |
db.getCollectionNames().forEach(function(c) { if (c.indexOf("system.") == -1) db[c].drop(); }) | |
// clear old profiles | |
db.setProfilingLevel(0); db.system.profile.drop(); db.setProfilingLevel(1, 100) | |
// view top profile queries | |
db.getCollection('system.profile').find({}, {ns: 1, query:1, millis:1, command: 1}).sort({millis:-1}) | |
//slow queries starting from a given date | |
db.getCollection('system.profile').find({ts: { $gte : new ISODate("2016-07-15T13:00:00.000Z") }}) | |
// index stats | |
db.collection.stats().indexSizes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment