Skip to content

Instantly share code, notes, and snippets.

@richmondwang
Last active April 4, 2018 07:21
Show Gist options
  • Save richmondwang/79cfe8f71ff7145bae75b05ad6687a45 to your computer and use it in GitHub Desktop.
Save richmondwang/79cfe8f71ff7145bae75b05ad6687a45 to your computer and use it in GitHub Desktop.
mongodb useful oneliner commands

Get index sizes of all collections in db

db.getCollectionNames().map(name => ({totalIndexSize: db.getCollection(name).stats().totalIndexSize, name: name})).sort((a, b) => a.totalIndexSize - b.totalIndexSize).forEach(printjson)

Memory stats

db.serverStatus().tcmalloc.tcmalloc.formattedString

Login to repl member with keyfile

mongo -u __system -p "$(tr -d '\011-\015\040' < path-to-keyfile)" --authenticationDatabase local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment