MongoDB TTL索引正在删除文档,但不会更新使用情况

问题描述 投票:1回答:1

我在Timestamp属性上构建了TTL索引,这是一个非常直接的索引。我使用MongoDb .Net Driver V 2.7.2在我的mongo上下文构造函数中创建了索引。它正在从给定的集合中删除预期的文档,但MongoDBCompass社区以及通过Mongo终端检查时“Usage”不会更新。

<code>
Here is the out put running $indexStat:

MongoDB Enterprise > db.testCollection.aggregate( [ { $indexStats: { } } ] ).pretty()
{
        "name" : "_id_",
        "key" : {
                "_id" : 1
        },
        "host" : "****:27017",
        "accesses" : {
                "ops" : NumberLong(15),
                "since" : ISODate("2018-12-20T22:52:01.132Z")
        }
}
{
        "name" : "****TTLIndex",
        "key" : {
                "Timestamp" : -1
        },
        "host" : "****:27017",
        "accesses" : {
                "**ops" : NumberLong(0),**  <----- This is zero
                "since" : ISODate("2018-12-20T22:52:01.132Z")
        }
}
</code>

enter image description here

什么可能导致使用不更新?其他集合上的其他TTL索引工作正常吗?

编辑我期待看到像这样的enter image description here

c# mongodb mongodb-.net-driver mongodb-compass
1个回答
1
投票

$ indexStats中的accesses值仅在用户请求驱动的索引访问时递增。这不包括后台TTL删除:

accessses字段报告的统计信息仅包括由用户请求驱动的索引访问。它不包括内部操作,如通过TTL索引删除或块拆分和迁移操作。

(Qazxswpoi)

© www.soinside.com 2019 - 2024. All rights reserved.