Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically kill slow MongoDB queries?

Is there a way that I can protect my app against slow queries in MongoDB? My application has tons of possibilities of filters and I'm monitoring all these queries but at the same time I don't want to compromise performance because of a missing index definition.

like image 900
Igor Escobar Avatar asked Nov 27 '12 12:11

Igor Escobar


1 Answers

The 'notablescan' option, as @ghik mentioned, will prevent you from running queries that are slow due to not using an index. However, that option is global to the server, and it is not appropriate for use in a production environment. It also won't protect you from any other source of slow queries besides table scans.

Unfortunately, I don't think there is a way to directly do what you want right now. There is a JIRA ticket proposing the addition of a $maxTime or $maxScan query parameter, which sounds like it would help you, so please vote for it: https://jira.mongodb.org/browse/SERVER-2212.

like image 97
acm Avatar answered Nov 15 '22 04:11

acm