Showing posts from January, 2013

MongoDB index completion status

MongoDB allows you to create indexes and run them in the background using the ensureIndex . Often indexing is a time consuming process and may take long if indexed upon string and the collection contains millions of records. For example, Indexing on my collection having 50 million records took almost 15 minutes. Here is the script that can be used to monitor index operation status. var ops = db.currentOp(); if(ops.inprog && ops.inprog.length > 0) {     for(o in ops.inprog) {         var op = ops.inprog[o];         if(op.msg && op.msg.match(/bg index build/)) {             print(op.opid+' - '+op.msg);         }     } } copy above code into, execute mongo and see the magic!!!