Guy Manzur
Guy Manzur

Reputation: 163

MongoDB - Clearing the cache using PyMongo

I'm using PyMongo to access MongoDB and I want to make some speed tests. However, the fact MongoDB uses cache makes it harder for me to do that. I know it's possible to clear cache using the Mongo Shell (I hope that's what I need) - but I can't find how to do that using PyMongo. Is it even possible? Thank you

Upvotes: 4

Views: 4820

Answers (1)

user3092503
user3092503

Reputation:

Here's how to execute the PlanCache.clear() command in PyMongo:

db.command(
    {
        "planCacheClear": "collection_name"
    }
)

Upvotes: 1

Related Questions