簡體   English   中英

如何通過shell查看MongoDB的索引創建進度

[英]How to check index creation progress in MongoDB via shell

在 MongoDB 中的數十億條記錄的大型集合中,提交了索引創建。 我運行db.getCollection('mycollection').aggregate([ { "$indexStats": { } } ] )並得到包含屬性building:true的結果。

問題:如何檢查索引構建的進度,例如完成百分比?

db.currentOp https://www.mongodb.com/docs/manual/reference/command/currentOp/

它返回很多,但您對command具有createIndexesmsg字符串包含“Index Build”的文檔感興趣。

如果 output 太吵,可以直接過濾運行 adminCommand:

db.adminCommand(
    {
      currentOp: true,
      $or: [
        { op: "command", "command.createIndexes": { $exists: true }  },
        { op: "none", "msg" : /^Index Build/ }
      ]
    }
)

文檔的現場progress顯示donetotal 你可以算一下。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM