db.currentOp() — MongoDB Technical Interview Questions & Answers

Lists operations currently running on the server.

db.currentOp()

  • Simple meaning: db.currentOp() lists operations running right now (slow queries, index builds).
  • How to use: in mongosh on a busy server. You can kill a runaway op with db.killOp(opid) — dangerous in production.
  • Common mistake: running killOp on a random id in a shared cluster.
  • Interview tip: “See in-flight work. Pair with profiler / explain for slow finds.”

Technical Interview Tip: currentOp = what is running now.

Code Examples for db.currentOp()

db.currentOp() — working example

db.currentOp({ active: true })

db.currentOp() — currentOp lists in-progress operations — useful when diagnosing slow queries.

How to Explain db.currentOp() to an Interviewer

When currentOp?

To see operations currently running on the server