Differences between revisions 4 and 5
Revision 4 as of 2020-04-19 22:22:45
Size: 1068
Editor: PieterSmit
Comment:
Revision 5 as of 2020-05-14 18:10:41
Size: 1395
Editor: PieterSmit
Comment:
Deletions are marked like this. Additions are marked like this.
Line 32: Line 32:

== From mongodb atlas help - how to view active connections ==
 * view active connections in shell {{{
db.currentOp(true).inprog.forEach( function(op) { if(op.active = true && op.client != undefined) { var miniOp = { client : op.client, description : op.desc }; printjson(miniOp);} } );

}}}
----
CategoryPerformance

MongoDb/Performance

Indicate in connection string to not use primary server in cluster

  • mongodb://user:pass@urls/db?readPreference=secondary&readPreferenceTags=nodeType:ANALYTICS&readConcernLevel=local

Slow / Long running queries

  • * $ mongo 10.32.2.4 --authenticationDatabase admin --username test --password mypass
  • > db.currentOp()

  • > db.currentOp({"secs_running": {$gte: 3}})

  • Count documents in <db> <collection>

    • use <db>;

    • db.<collection>.count()

  • DB locks
    • > db.serverStatus().globalLock

    • > db.serverStatus().locks

  • DB version , want > 3.2 wiretiger document level locking

    • > db.version()

  • DB memory usage should be less than ram
    • > db.serverStatus().mem

    • > db.serverStatus().wiredTiger.cache

  • Check number of connections
    • db.serverStatus().connections
  • Check indexs on a collection
    • db.<collection>.getIndexes()

From mongodb atlas help - how to view active connections

  • view active connections in shell

    db.currentOp(true).inprog.forEach( function(op) { if(op.active = true && op.client != undefined) { var miniOp = { client : op.client, description : op.desc }; printjson(miniOp);}  } );


CategoryPerformance

MongoDb/Performance (last edited 2020-05-14 18:10:41 by PieterSmit)