-
Book Overview & Buying
-
Table Of Contents
Mastering MongoDB 6.x - Third Edition
By :
When connecting to our production MongoDB servers, we want to make sure that our operations are as lightweight as possible (and are certainly non-destructive) and do not alter the database state in any sense.
Two useful utilities that we can chain to our queries are shown here:
> db.collection.find(query).maxTimeMS(999)
Our query instance will only take up to 999 milliseconds (ms), and will then return an exceeded time limit error, as follows:
> db.collection.find(query).maxScan(1000)
Our query instance will examine 1000 documents at the most, in order to find results and then return (no error raised).
Whenever we can, we should bind our queries by time or document result size to avoid running unexpectedly long queries that may affect our production database. A common reason for accessing our production database is troubleshooting degraded cluster performance. This can be investigated via cloud monitoring tools, as we described in previous...