列出當前執行的查詢

以下命令列出了當前正在伺服器上執行的查詢

db.currentOp()

輸出看起來與此類似

{
    "inprog" : [
        {
            "opid" : "302616759",
            "active" : true,
            "secs_running" : 1,
            "microsecs_running" : NumberLong(1167662),
            "op" : "getmore",
            "ns" : "local.oplog.rs",
            "query" : {
                
            },
            ...
        },
        {
            "desc" : "conn48",
            "threadId" : "0x114c00700",
            "connectionId" : 48,
            "opid" : "mdss_shard00:302616760",
            "active" : true,
            "secs_running" : 1,
            "microsecs_running" : NumberLong(1169659),
            "op" : "getmore",
            "ns" : "local.oplog.rs"
            ...
        }
    ]
}

inprog 屬性表示查詢當前正在進行中。opid 是查詢或操作的 Id。secs_running 表示它執行的時間。這有時可用於識別長時間執行的查詢。