-
Notifications
You must be signed in to change notification settings - Fork 1
Description
During development, I noticed that no mongo index has been setup on the key
parameter due to a notablescan
parameter being enable on my local mongo developement, to catch any potentially slow queries from being run. This means that every time a key lookup is done (in the findOneAndUpdate
method), mongo does a full scan of all documents in the throttler
collection. Though small numbers of documents are unlikely to cause issues for smaller number of keys, larger numbers of keys are very likely to cause degraded lookup times (see https://www.mongodb.com/docs/upcoming/reference/glossary/#std-term-collection-scan).
I'd recommend adding an index using the key
parameter to resolve this issue. I don't anticipate that this would cause significant slowdown during insertion time (minor increase to insertion time), but result in moderate improvements to lookup/update times as key count increases.
When creating the indexes, the following index could be added to address this:
.createIndex({ key: 1 })