Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check the index creation progress in mongo DB using java driver

I have around 10 millions of data in MongoDB. There is a requirement to add a new compound index. I used the following code to create the index. Using ensureIndex with option creation in background.

MongoStore.ads().ensureIndexes("MyCollection", MyCollection.class, true);

My question is how do I track the index creation progress. There are other sets of operations I need to do after confirming the Index is created 100%.

Please help me with how I do check the progress in java.

I am using mongo-java-driver 3.5 version.

like image 404
Parveen Avatar asked Oct 15 '25 04:10

Parveen


1 Answers

You cann't monitor them with mongo-java driver. But, you can monitor the created indexes in your Mongo shell:

db.currentOp({"command.createIndexes": { $exists : true } }).inprog.forEach(function(op){ print(op.msg) })

This will return the output like:

Index Build (background) Index Build (background): 83727/271147 30%

For more about currentOp() refer here.

Hope this will help :)

like image 69
Vijay Rajpurohit Avatar answered Oct 17 '25 19:10

Vijay Rajpurohit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!