jueves, 28 de diciembre de 2017

Script - MongoDB stats, execution plans and clearing

Some usefull methods to review and clear execution plans in MongoDb

MongoDB stats, collections stats

db.stats()
db.<collection>.stats()

Execution plans clearing, needed if an incorrect execution plan appears and you need to refresh them.

db.<collection>.getPlanCache().clear()

Show execution plans by collection or by query

db.<collection>.getPlanCache().listQueryShapes()
db.<collection>.getPlanCache().getPlansByQuery({
        "query" : {
            "$or" : [
                {
                    "key1" : "value1",
                    "key2" : "value2"
                }
            ],
            "key3" : "value3"
        },
        "sort" : {},
        "projection" : {}
    })

No hay comentarios:

Publicar un comentario