根据文档 count
和distinct
查询应该导致op
=count
和op
= distinct
in system.profile
。但是,当我尝试在 shell 中运行此类查询时,它们都生成为op
= command
。
> db.p.count()
23
> db.p.distinct("item")
[ "pencil", "eraser" ]
> db.system.profile.find().sort({$natural: -1}).limit(2).pretty()
{
"op" : "command",
"ns" : "test.p",
"command" : {
"distinct" : "p",
"key" : "item",
"query" : {
}
},
(...)
}
{
"op" : "command",
"ns" : "test.p",
"command" : {
"count" : "p",
"query" : {
},
"fields" : {
}
},
(...)
}
因为remove
这个工作非常好,我执行remove
并得到op
= remove
in system.profile
。
> db.p.remove({item: "pen"})
WriteResult({ "nRemoved" : 0 })
> db.system.profile.find().sort({$natural: -1}).limit(1).pretty()
{
"op" : "remove",
"ns" : "test.p",
"query" : {
"item" : "pen"
},
(...)
}