MongoDB Documentation, Release 3.0.4 Available Procedures Related Analyze Performance of Database Operations 5.2. Administration Tutorials 227 The database profiler writes all the data it collects to the system.profile (page 291) collection, which is a capped collection (page 209). See Database Profiler Output (page 292) for overview of the data in the system.profile (page 291) documents created by the profiler. The database profiler collects fine grained data about MongoDB write operations, cursors, database commands on a running mongod instance. You can enable profiling on a per-database or per-instance basis. The profiling level (page 228) is also configurable when enabling profiling. Warning: Terminate running operations with extreme caution. Only use db.killOp() to terminate operations initiated by clients and do not terminate internal database operations. To return a list of running operations see db.currentOp() . db.killOp(<opId>) killOp The db.killOp() method interrupts a running operation at the next interrupt point . db.killOp() identifies the target operation by operation ID. db.getLastError() and db.getLastErrorObj() will return errors for interrupted options: You can add the maxTimeMS field to the command document to set a time limit of 45 milliseconds for the operation: db.runCommand( { distinct: "collection", key: "city" } ) Terminate a Command Consider a potentially long running operation using distinct to return each dis- tinct‘‘collection‘‘ field that has a city key: db.location.find( { "town": { "$regex": "(Pine Lumber)", "$options": 'i' } } ).maxTimeMS(30) Terminate a Query From the mongo shell, use the following method to set a time limit of 30 milliseconds for this query: The maxTimeMS() method sets a time limit for an operation. When the operation reaches the specified time limit, MongoDB interrupts the operation at the next interrupt point . maxTimeMS New in version 2.6. db.runCommand( { distinct: "collection", key: "city", maxTimeMS: 45 } ) { "n" : 0, "connectionId" : 1, "err" : "operation exceeded time limit", "ok" : 1 }