Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoDB find a query that throws alert

So I am getting an alert from Mongo - occasionally...

Query Targeting: Scanned Objects / Returned has gone above 1000

Is there a way to see the offending query specifically? I see graphs of trends over time in my dashboard - my "performance advisor" shows no "slow" queries...and the emails alert I get specifically says to check "performance advisor".

Any help

like image 298
j-p Avatar asked Mar 05 '19 16:03

j-p


1 Answers

Normally, when the Scanned Object / Returned ratio is large, that means that those queries will be slow and will show up in the slow_query log. If nothing is showing up there, you can reduce the slowms setting that determines which queries will be written to the slow query log.

$explain and the $collStats aggregation operator are two other tools that are worth being aware of, but for this case I'd recommend updating your profiling level (db.setProfilingLevel) and then seeing where you're at!

If you're using Atlas, the "Profiler" tab shows the queries from the slow query log in an explorable way. If you're not on atlas, mtools has some good mongo log parsing tools.

like image 86
willis Avatar answered Nov 02 '22 05:11

willis