MongoDB Analyzer:
To detect if the MongoDB parser is open:
Db.getprofilinglevel ()
- 0 indicates no open
- 1 means open, and if the query execution time exceeds the maximum query execution time for the second parameter in milliseconds (ms), it is logged or ignored.
- 2 means open, and all query statements are logged
Db.setprofilinglevel (2)
A System.profile collection is found in the test database at this point: but this collection is still empty.
Then we make a query Db.comments.find ({timestamp:6})
Then query the collection: Db.system.profile.find (). Pretty (), we can see the execution plan of the query just now.
"nreturned": 1 returns the number of rows 1
"Millis": 0 Execution time
"Stage": "Collscan" not used Index
"docsexamined": 81 scan of 8 documents
Thus, we can pass the statement: Db.system.profile.find ({"Query.find": "Comments"}). Sort ({"TS":-1}). Limit (1). Pretty () Queries out the latest execution plan in the specified statement.
System.profile The default size of the collection is 1024KB=1MB, let's expand its size:
- Close the MongoDB parser
- Delete System.profile Collection
- Create 50M fixed-size collections
MongoDB explain:
Analyze a specific query with explain
Db.comments.find ({timestamp:6}). Explain (true)
MongoDB Learning Notes Analyzer and explain