On a large collection of billions records in MongoDB an index creation is submitted.
I run db.getCollection('mycollection').aggregate([ { "$indexStats": { } } ] ) and i get result containing property building:true.
Question: How could I check the progress of the index building e.g. percentage complete?
CodePudding user response:
db.currentOp https://www.mongodb.com/docs/manual/reference/command/currentOp/
It returns a lot, but you are interested in a document where command has createIndexes or msg string contains "Index Build".
If the output is too noisy, you can filter running adminCommand directly:
db.adminCommand(
{
currentOp: true,
$or: [
{ op: "command", "command.createIndexes": { $exists: true } },
{ op: "none", "msg" : /^Index Build/ }
]
}
)
The field progress of the document reveals done and total. You can do the math.
