PyMongo Aggregate how to get executionStats
Asked Answered
O

1

7

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

Overcautious answered 22/5, 2019 at 9:5 Comment(1)
Which version of PyMongo and MongoDB ?Ashleeashleigh
D
12

This worked for me:

db.command(
    'explain', 
    {
        'aggregate': coll_name, 
        'pipeline': your_pipeline, 
        'cursor': {}
    }, 
    verbosity='executionStats'
)
Drachma answered 8/4, 2020 at 15:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.