MongoDB TTL 索引正在删除文档,但未更新用法
MongoDB TTL Index is removing documents but usage is not updated
我在 Timestamp 属性 上建立了 TTL 索引,这是一个非常直接的索引。我已经使用 MongoDb .Net Driver V 2.7.2 在我的 mongo 上下文构造函数中创建了索引。
它正在按预期从给定集合中删除文档,但 "Usage" 未在 MongoDBCompass 社区以及我通过 Mongo 终端检查它时更新。
<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>
可能导致使用情况不更新的原因是什么?其他集合上的其他 TTL 索引工作正常?
编辑
我期待看到这样的事情
$indexStats 中的 accesses
值仅在用户请求驱动的索引访问时递增。这不包括后台 TTL 删除:
The statistics reported by the accesses field only includes index
access driven by user requests. It does not include internal
operations like deletion via TTL Indexes or chunk split and migration
operations.
(https://docs.mongodb.com/manual/reference/operator/aggregation/indexStats/)
我在 Timestamp 属性 上建立了 TTL 索引,这是一个非常直接的索引。我已经使用 MongoDb .Net Driver V 2.7.2 在我的 mongo 上下文构造函数中创建了索引。 它正在按预期从给定集合中删除文档,但 "Usage" 未在 MongoDBCompass 社区以及我通过 Mongo 终端检查它时更新。
<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>
可能导致使用情况不更新的原因是什么?其他集合上的其他 TTL 索引工作正常?
编辑
我期待看到这样的事情
$indexStats 中的 accesses
值仅在用户请求驱动的索引访问时递增。这不包括后台 TTL 删除:
The statistics reported by the accesses field only includes index access driven by user requests. It does not include internal operations like deletion via TTL Indexes or chunk split and migration operations.
(https://docs.mongodb.com/manual/reference/operator/aggregation/indexStats/)