简体   繁体   English

空集合上的MongoDB更新很慢

[英]MongoDB update is slow on an empty collection

I have a Java Spring application that periodically (every 10 seconds) performs an update on my database, a 3 node replica set. 我有一个Java Spring应用程序,它定期(每10秒)对数据库(一个3节点副本集)执行更新。

The performance of the update varies substantially between calls. 两次调用之间,更新的性能差异很大。 What is surprising is that when the collection is empty I have noticed the following in the logs: 令人惊讶的是,当集合为空时,我在日志中注意到以下内容:

2018-01-23T11:02:37.941+0000 I COMMAND  [conn18] command myCollection.$cmd command: update { update: "myCollection", ordered: true, writeConcern: { w: "majority" }, updates: [ { q: { lockExpiry: { $lte: 1516705340965 } }, u: { $set: { isLocked: false } }, multi: true } ] } keyUpdates:0 writeConflicts:0 numYields:0 reslen:115 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_query 10555ms

Any reason why such a query could be taking this long? 为什么这样的查询要花这么长时间呢? I am using MongoDB 3.2 with the WiredTiger storage engine, the collection does not have an index. 我将MongoDB 3.2和WiredTiger存储引擎一起使用,该集合没有索引。

You're running against a replica set, and you've got writeConcern "majority" specified. 您正在针对副本集运行,并且已指定了writeConcern“多数”。 Could the delay be due to latency between the nodes perhaps? 延迟可能是由于节点之间的延迟引起的吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM