gpt4 book ai didi

mongodb - oplog.rs 中 ts 字段的索引未更新

转载 作者:行者123 更新时间:2023-12-02 17:29:52 25 4
gpt4 key购买 nike

我有一个应用程序,它通过查询 ts 字段来读取 mongodb 2.2 副本集中的 oplog.rs 集合。

我在 ts 字段上添加了索引,但当新条目插入到 oplog 中时它不会更新。

我错过了什么?我在 mongodb 文档中找不到任何关于不支持上限集合索引的内容(相反),并且我找不到任何有关 oplog 特殊的信息。

谢谢

最佳答案

正如您所发现的,local.oplog.rs*.system.profile 等系统集合不支持二级索引。在 MongoDB 2.4 及更早版本中,索引似乎已经创建,但实际上从未更新。如果您尝试使用不受支持的更改(例如尝试创建其他索引)直接更新系统集合,较新版本的 MongoDB (2.6+) 将返回错误。

oplog.rs 集合绝对是“特殊的”,因为它的预期用途仅用于复制。复制内部在此基础上对oplog的预期操作做出一些假设。例如,复制只需要插入 oplog 条目 - 与您自己创建的上限集合不同,oplog 条目永远不会更新。

应用程序预计会读取带有 tailable cursor 的 oplog如果他们需要跟踪插入到 oplog 中的新条目,或者使用 $natural order 进行查找.

tailable cursor tutorial详细介绍了使用方法,但需要注意的一些具体要点是:

  • Tailable cursors do not use indexes and return documents in natural order.
  • Because tailable cursors do not use indexes, the initial scan for the query may be expensive; but, after initially exhausting the cursor, subsequent retrievals of the newly added documents are inexpensive

关于mongodb - oplog.rs 中 ts 字段的索引未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15389325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com