DEV Community


slow mongo queries

Tony Colston
wanna be gamedev ... all around nerd and dev
・1 min read

You can find long running mongo queries with this

db.currentOp({"secs_running": {$gte: 20}}) 

That will list current operations that have been running at least 20 seconds and longer.

Look at that list that returns and find opid out of each element. Also read each element some of the queries there could be system processes (or at least it looked like it for me).

Then for each opid you want to kill run this


The opid in my case was an int (a big one) so an example of what it looked like was this:


That should save you some reboots or service restarts!

Discussion (0)