背景 中午12点半,接到了线上MongoDB 数据库异常的告警通报: “CPU不间断飙升到百分百,业务也相应出现了抖动现象。” 通过排查数据库主节点的日志,发现了这样的一个慢语句: 2019-03-07T10:56:43.470+0000 I COMMAND [conn2544772] command nlp.ApplicationDevice appName: "nlp" command: find { find: "ApplicationDevice", filter: { appId: "Gf93VvCfOdttrxSOemt_03ff", tags.tagName: "pipeline", tags.tagValue: "multi", _id: { $gt: ObjectId('000000000000000000000000') } }, projection: { $sortKey: { $meta: "sortKey" } }, sort: { _id: 1 }, limit: 10, shardVersion: [ Timestamp 1000|1000, ObjectId('5c64f941c81e2b922e48e347') ] } planSummary: IXSCAN { appId: 1, tags.tagName: 1, tags.tagValue: