Docs 主页 → 开发应用程序 → MongoDB Manual
top
定义
对于每个集合, top
返回每个事件执行所需的time
量(以微秒为单位)以及每个事件已执行的次数的count
。 time
和count
指标仅在您重新启动mongod
实例后重置。
日志校订
使用 Queryable Encryption 时,top
命令仅返回集合名称。
语法
db.runCommand( { top: 1 } )
事件字段
top
命令会返回以下事件字段的使用统计信息:
字段 | 说明 |
---|---|
total | 所有 readLock 和 writeLock 操作的组合。 |
readLock | 使用读锁的操作的使用统计。这些操作包括但不限于查询和聚合。 |
writeLock | 使用写锁的操作的使用情况统计信息。这些操作包括但不限于插入、更新和删除文档。 |
queries | 查询操作(如 find )的使用统计。queries.time 和 queries.count 字段也会更新 readLock.time 并递增 readLock.count 。 |
getmore | getMore 操作的使用统计。getmore.time 和 getmore.count 字段也会更新 readLock.time 并递增 readLock.count 。 |
insert | insert 操作的使用统计。insert.time 和 insert.count 字段也会更新 readLock.time 并递增 readLock.count 。 |
update | update 操作的使用统计。update.time 和 update.count 字段也会更新 readLock.time 并递增 readLock.count 。 |
remove | delete 操作的使用统计。remove.time 和 remove.count 字段也会更新 readLock.time 并递增 readLock.count 。 |
commands | 聚合、创建索引和删除索引等操作的使用情况统计信息。根据命令类型, 例如,聚合操作会递增 |
例子
top
命令的输出类似于以下输出:
{ "totals" : { note: "all times in microseconds", "records.users" : { "total" : { "time" : 305277, "count" : 2825 }, "readLock" : { "time" : 305264, "count" : 2824 }, "writeLock" : { "time" : 13, "count" : 1 }, "queries" : { "time" : 305264, "count" : 2824 }, "getmore" : { "time" : 0, "count" : 0 }, "insert" : { "time" : 0, "count" : 0 }, "update" : { "time" : 0, "count" : 0 }, "remove" : { "time" : 0, "count" : 0 }, "commands" : { "time" : 0, "count" : 0 } } }