Skip to content

Instantly share code, notes, and snippets.

@jbutko
Last active May 7, 2018 20:42
Show Gist options
  • Save jbutko/c7136a81352a3e81355e6fd03c886ccb to your computer and use it in GitHub Desktop.
Save jbutko/c7136a81352a3e81355e6fd03c886ccb to your computer and use it in GitHub Desktop.
MongoDB cheat sheet

explain find query

db.collection.find({...}).explain('executionStats')

  • or allPlansExecution

explain aggregate

db.collection.explain('executionStats').aggregate([{...}])

get indexes

db.collection.getIndexes()

force usage of specific index in query

db.collection.find({...}).hint('index_name_1')

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