Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 868
Guy Manzur Avatar asked Nov 08 '22 22:11

Guy Manzur


1 Answers

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

db.command(
    {
        "planCacheClear": "collection_name"
    }
)
like image 198
arbitrarystringofletters Avatar answered Nov 15 '22 05:11

arbitrarystringofletters