Skip to content

COLLSCAN on key lookups #103

@jordanchip

Description

@jordanchip

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 })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions