Table of Contents

MongoDB - Tips & Tricks

This article is just a reference for useful patterns, queries, tips and tricks regarding MongoDB and its python clients.

Operations

maybe the following can be helpful to check whats running on a db (monitoring?)

db.currentOP(true)

Indexing

get the total index size for a collection:

db.getCollection('meta_db_collection').totalIndexSize()

when creating an index in background, check the progress:

db.currentOp(true).inprog.forEach(function(op){ if(op.msg!==undefined) print(op.msg) })

Tags

mongo, pymongo, motor, index