MongoDB Learning Notes Analyzer and explain

Source: Internet
Author: User

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:

    1. Close the MongoDB parser
    2. Delete System.profile Collection
    3. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.