Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyMongo Aggregate how to get executionStats

I am trying to get executionStats of a Particular mongo aggregate query. I run db.command but that doesn't give "execution status"

This is what I am trying to do. how to get Python Mongo Aggregate explain using db.command?

pymongo aggregate don't allow explain option

like image 333
Bhavani Ravi Avatar asked Oct 15 '22 14:10

Bhavani Ravi


1 Answers

This worked for me:

db.command(
    'explain', 
    {
        'aggregate': coll_name, 
        'pipeline': your_pipeline, 
        'cursor': {}
    }, 
    verbosity='executionStats'
)
like image 187
warvariuc Avatar answered Oct 29 '22 06:10

warvariuc