Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use query.explain() of mongodb from mongoengine

I am trying analyze my query performances and would like improve them. I use mongoengine wrapper. I am not able find way to use explain() from mongoengine although I am using query logs and getting the raw mongo queries and running explain I would like to use explain via mongoengine to make my monitoring less cumbersome. Any ideas

like image 770
Krishna Teja Avatar asked Oct 08 '13 08:10

Krishna Teja


People also ask

How does MongoDB query work?

MongoDB keeps most recently used data in RAM. If you have created indexes for your queries and your working data set fits in RAM, MongoDB serves all queries from memory. MongoDB does not cache the query results in order to return the cached results for identical queries.

How fetch data from MongoDB?

You can use read operations to retrieve data from your MongoDB database. There are multiple types of read operations that access the data in different ways. If you want to request results based on a set of criteria from the existing set of data, you can use a find operation such as the find() or findOne() methods.

Which is better PyMongo or MongoEngine?

Both PyMongo and MongoEngine can be used to access data from a MongoDB database. However, they work in very different ways and offer different features. PyMongo is the MongoDB recommended library. It makes it easy to use MongoDB documents and maps directly to the familiar MongoDB Query Language.


1 Answers

You can use explain eg:

MyDoc.objects(x=y).explain()

See: QuerySet.explain()

like image 83
Ross Avatar answered Oct 18 '22 09:10

Ross