In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is about how mongo queries slow logs and creates indexes. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Check whether the mongodb slow log is on.
Use LogDB
Db.getProfilingStatus ()
two。 Open the slow log and set the operation for more than 100 milliseconds as a slow operation
Db.setProfilingLevel (1100)
3. View slow log content
Db.system.profile.find () .sort ({$natural:-1})
Journal,
Shard3:PRIMARY > db.system.profile.find () .sort ({$natural:-1})
{"op": "query", "ns": "LogDB.Flashxxx", "command": {"find": "Flashxxx", "filter": {"UserId": {"$in": ["1111111"]}}, "shardVersion": [Timestamp (0,0), ObjectId ("0000000000000000000000000"), "lsid": {"id": UUID ("d08179ba-ecbd-4f9d-92e7-cd491e5a1d8a") "uid": BinData (0, "iwsImy7Wfk2mAp4o/uuD+I9mpETQTxb5PXo26pIQkS4=")}, "$clusterTime": {"clusterTime": Timestamp (1558696199, 3), "signature": {"hash": BinData (0, "Ht7EWhYpVLiy+DbH8Cu1Ijs6PNk="), "keyId": NumberLong ("6647500774429425691")}}, "$client": {"driver": {"name": "mongo-csharp-driver", "version": "2.7.0.0"} "os": {"type": "Windows", "name": "Microsoft Windows 6.3.9600", "architecture": "x8600064", "version": "6.3.9600"}, "platform": ".NET Framework 4.0.0.0", "mongos": {"host": "new-mongo01:20000", "client": "10.205.33.32 name 59518" "version": "3.6.9"}, "$configServerState": {"opTime": {"ts": Timestamp (1558696196, 12), "t": NumberLong (3)}}, "$db": "LogDB"}, "keysExamined": 0, "docsExamined": 37428, "cursorExhausted": true, "numYield": 37428 "locks": {"Global": {"acquireCount": {"r": NumberLong}}, "Database": {"acquireCount": {"r": NumberLong (293)}}, "Collection": {"acquireCount": {"r": NumberLong (293)}, "nreturned": 1, "responseLength": 673, "protocol": "op_msg" "millis": 104, "planSummary": "COLLSCAN", "execStats": {"stage": "COLLSCAN", "filter": {"UserId": {"$eq": "11111111115"}}, "nReturned": 1, "executionTimeMillisEstimate": 100, "works": 37430, "advanced": 1, "needTime": 37428, "needYield": 0, "saveState": 37428 "restoreState": 292, "isEOF": 1, "invalidates": 0, "direction": "forward", "docsExamined": 37428}, "ts": ISODate ("2019-05-24T11:09:59.346Z"), "client": "10.205.34.91", "allUsers": [{"user": "_ system", "db": "local"}] "user": "_ _ system@local"}
Note that COLLSCAN is a full table scan.
View the execution plan:
Db.FlashClientData.find ({UserId: 1000493111}) .explain ()
Shard3:PRIMARY > db.FlashClientData.find ({UserId: 100049111}). Explain ()
{
"queryPlanner": {
"plannerVersion": 1
"namespace": "LogDB.Flashxxx"
"indexFilterSet": false
"parsedQuery": {
"UserId": {
"$eq": 10x0493111
}
}
"winningPlan": {
"stage": "COLLSCAN"
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.