In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Mongodb how to use profiling slow request monitoring log, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
0: off without collecting any data.
1: collect slow query data. Default is 100 milliseconds.
2: collect all data
View Profiling and Settings
Db.getProfilingStatus ()
Set log collection level and time
Db.setProfilingLevel (1m 3000)
Db.system.profiling.find () .sort ({$natural:-1}) .limit (30)
If the above operations are under the test collection, it is only valid for the operations in the collection. If you need to be valid for the entire instance, you need to set the parameters under all collections or enable the parameters when enabled:
Close Profiling
Db.setProfilingLevel (0)
Parameter meaning
Drug:PRIMARY > db.system.profile.find (). Pretty ()
{
"op": "query", # operation type, such as insert, query, update, remove, getmore, command
"ns": "mc.user", collection of # operations
"query": {# query statement
"mp_id": 5
"is_fans": 1
"latestTime": {
"$ne": 0
}
"latestMsgId": {
"$gt": 0
}
"$where": "new Date (this.latestNormalTime) > new Date (this.replyTime)"
}
"cursorid": NumberLong ("1475423943124458998")
"ntoreturn": the number of records returned by 0, # For example, the profile command will return a document (a result file), so the ntonotify value will be 1. The limit (5) command returns five files, so the ntonotify value is 5. If the ntonotify value is 0, the command does not specify that some files are returned, because such a simple find () command has no specified limit.
"ntoskip": the number of hops specified by the # skip () method
"nscanned": 304,# number of scans
"keyUpdates": 0, # number of index updates, changing an index key carries a small performance overhead because the database must delete the old key and insert a new key into the B-tree index
"numYield": 0, # the number of times this query frees locks for other queries
"lockStats": {# lock information, R: global read lock; W: global write lock; r: specific database read lock; w: specific database write lock
"timeLockedMicros": {# lock
"r": NumberLong (19467)
"w": NumberLong (0)
}
"timeAcquiringMicros": {# Lock waiting
"r": NumberLong (7)
W: NumberLong (9)
}
}
"nreturned": 101,# number of returns
"responseLength": 74659, # response byte length
"millis": 19, # time consumed (milliseconds)
"ts": ISODate ("2014-02-25T02:13:54.899Z"), # time the statement was executed
"client": "127.0.0.1", # Link ip or host
"allUsers": []
"user": # user
}
ScanAndOrder:
ScanAndOrder is a Boolean value that is True when the order of files that cannot be used by a query is sorted in the index: the MongoDB must sort the files it receives from a file after a cursor.
If scanAndOrder is False,MongoDB, you can use the sequential index of these files to return the sorted results. That is, True: documents are sorted, and False: indexes are used.
Moved
The update operation moves one or more files to a new location on disk. Indicates whether the update has moved the data on the hard disk. If the new record is shorter than the original record, it usually does not move the current record. If the new record is longer than the original record, it may move the record to another location, which will lead to the update of the relevant index. More disk operations, plus indexing
Updates will make such operations slower.
Moved:
The file operates on disk.
Nupdated:
Number of updated documents
Getmore is a getmore operation. Getmore usually occurs in a query with a large result set. The first query returns part of the results, and the subsequent results are obtained through getmore.
Query operations for daily use of profiling
Return to the last 10 records
Db.system.profile.find (). Limit (10). Sort ({ts:-1}). Pretty ()
# returns all operations except those of type command
Db.system.profile.find ({op: {$ne: 'command'}}) .pretty ()
# return a specific collection
Db.system.profile.find ({ns: 'mydb.test'}) .pretty ()
# return operations that are more than 5 milliseconds slow
Db.system.profile.find ({millis: {$gt: 5}}) .pretty ()
# return information from a specific time range
Db.system.profile.find (
{
Ts: {
Gt: new ISODate ("2012-12-09T03:00:00Z")
Lt: new ISODate ("2012-12-09T03:40:00Z")
}
}
). Pretty ()
# specific time, limit users, and sort by elapsed time
Db.system.profile.find (
{
Ts: {
Gt: new ISODate ("2011-07-12T03:00:00Z")
Lt: new ISODate ("2011-07-12T03:40:00Z")
}
}
{user: 0}
). Sort ({millis:-1}
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.