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 test_index_status.sh, execute mongo index_status.sh and see the magic!!!



Comments

navya said…
Wow. This really made my day. Thanks a lot!

JavaScript Training in CHennai JavaScript Training in CHennai JQuery Online Training JQuery Online Training
HTML5 CSS3 JavaScript Training in Chennai | HTML5 Online Training
navya said…
Wow. This really made my day. Thanks a lot!

JavaScript Training in CHennai HTML5 Training in Chennai HTML5 Training in Chennai JQuery Training in Chennai JQuery Training in Chennai JavaScript Training in Chennai JavaScript Training in Chennai


Popular posts from this blog

Proper way to have an anchor tag with onclick event

Some thoughts on MongoDB Nodejs driver

CORS issues with IE9 and workarounds