草庐IT

firstTimestamp

全部标签

MongoDB 复合索引优化键和范围条件更新

已阅读thisdoc,它指出索引可以优化更新操作。然后,我将索引添加到我的集合中以优化我正在使用的更新操作。集合中的记录具有作为_id的对象和时间戳:{_id:{userId:"sample"},firstTimestamp:123,otherField:"abc"}我想做的是使用下面的查询操作更新:db.userFirstTimestamp.update({_id:{userId:"sample"},firstTimestamp:{$gt:100}},{_id:{userId:"sample"},firstTimestamp:100,otherField2:"efg"})我想根据'f