db:statistics collection:uart_logs 32w 条数据,每条多层文档结构 serial_server 字段 asc 索引
手写 query db.uart_logs.find({serial_server:"10.30.40.233"}).limit(1) 查询时间 0.75s mgo 封装后 query db.uart_logs.find({ find: "uart_logs", filter: { serial_server: "10.30.40.233" }, limit: 1 , $db: "statistics" }) 查询时间 23s 这样子手写 db.collection.find({ find: "uart_logs", filter: { serial_server: "10.30.40.233" }, limit: 1 , $db: "statistics" }) 也是 1s 内
mongodb log
2022-11-07T14:39:15.592+0800 I COMMAND [conn6] command statistics.uart_logs command: find { find: "uart_logs", filter: { serial_server: "10.30.37.233", time: new Date(1667800800000) }, limit: 1, singleBatch: true, lsid: { id: UUID("934fd6f4-3e07-4697-b381-5e329799fbf2") }, $db: "statistics" } planSummary: COLLSCAN keysExamined:0 docsExamined:326818 cursorExhausted:1 numYields:2588 nreturned:1 queryHash:589B9D08 planCacheKey:589B9D08 reslen:61527 locks:{ ReplicationStateTransition: { acquireCount: { w: 2589 } }, Global: { acquireCount: { r: 2589 } }, Database: { acquireCount: { r: 2589 } }, Collection: { acquireCount: { r: 2589 } }, Mutex: { acquireCount: { r: 1 } } } storage:{ data: { bytesRead: 916177929, timeReadingMicros: 572959 }, timeWaitingMicros: { cache: 20 } } protocol:op_msg 12574ms
请问各位大佬什么原因
1
zsj1029 OP 远程 mongodump 三个小时 这 32w 条数据还没 dump 下来
|
2
zsj1029 OP sorry 搞错了,用的官方推荐的 go.mongodb.org/mongo-driver/mongo
|
3
wumoumou 2022-11-08 09:46:05 +08:00
向大佬学习
|
4
tikazyq 2022-11-14 09:41:55 +08:00
大概率是没加索引
db.uart_logs.getIndexes() |