2015-08-25

MongoDB - Explaining queries (plan and actual execution explanation)

db.COLLECTION_NAME.explain().find({FILTER_HERE});

// This will explain the actual execution (execute and explain)
db.COLLECTION_NAME.explain(true).find({FILTER_HERE});


// Including execution statistics (more verbose than regular explain)
db.COLLECTION_NAME.explain("executionStats").find({FILTER_HERE});


PS. The explain method does not only apply to .find() but also to .aggregate(), .count(), .group(), .remove(), .update()

No comments:

Post a Comment