"Go" MongoDB can monitor data via profile (MongoDB performance optimization)

Source: Internet
Author: User

turn on the Profiling function To optimize for slow queries:

MongoDB can monitor data through profile to optimize it.

To see whether the profile function is currently open with commands

Db.getprofilinglevel () returns level with a value of 0|1|2, meaning: 0 for off, 1 for slow command, 2 for all

Db.setprofilinglevel (level); #level等级, value ibid.

At level 1, the slow command defaults to 100ms and changes to Db.setprofilinglevel (LEVEL,SLOWMS) such as Db.setprofilinglevel (1,50) to 50 milliseconds.

View the current monitoring log through Db.system.profile.find ().

Such as:

> Db.system.profile.find ({millis:{$gt: $}}) {"TS": Isodate ("2011-07-23t02:50:13.941z"), "info": "Query Order.order reslen:11022 nscanned:672230  \nquery: {status:1.0} nreturned:101 bytes:11006 640ms "," Millis ": 640} { "TS": Isodate ("2011-07-23t02:51:00.096z"), "info": "Query Order.order reslen:11146 nscanned:672302  \nquery: { status:1.0, User.uid: {$gt: 1663199.0}}  nreturned:101 bytes:11130 647ms "," Millis ": 647}

The meaning of the value here is

ts: Command Execution time

Info: Contents of the command

Query: Representative queries

Order.order: The Library and collection representing the query

Reslen: Returned result set size, byte number

nscanned: Number of scanned records

Nquery: The following is the query condition

Nreturned: Returns the number of records and the elapsed time

Millis: The time spent

If you find that time is longer, you need to optimize it.

For example, if the number of nscanned is large or close to the total number of records, then the index query may not be used.

The Reslen is large, and it is possible to return unnecessary fields.

Nreturned is very large, it is possible to query the time without adding restrictions.

Translated from: http://my.oschina.net/baowenke/blog/97756

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.