Skip to content

slow mongodb performance: indexes on mongodb does not match the queries #3

@cwolters

Description

@cwolters

Hi.

I observed a very slow response of mongo while having a lot of thoughts in the system.
The query behind the scene is doing something like:

db.getCollection('thoughts').find({}).sort({"time":-1}).limit(1500)

There is no index on reverse time - so adding an index by:

db.thoughts.createIndex({"time":-1})

speeded the processing up to factor 10.

So you may add something like:

get('db.mongo.db').collection('thoughts').ensureIndex({app: 1, time: 1, key: 1}, done)

to indexes.js

There are some more of these missing indexes in there ... ;-)

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