MongoDB querying performance for over 5 million records

后端 未结 3 949
礼貌的吻别
礼貌的吻别 2020-12-12 09:22

We\'ve recently hit the >2 Million records for one of our main collections and now we started to suffer for major performance issues on that collection.

They documen

3条回答
  •  借酒劲吻你
    2020-12-12 09:49

    Mongo only uses 1 index per query. So if you want to filter on 2 fields, mongo will use the index with one of the fields, but still needs to scan the entire subset.

    This means that basically you'll need an index for every type of query in order to achieve the best performance.

    Depending on your data, it might not be a bad idea to have one query per field, and process the results in your app. This way you'll only need indexes on every fields, but it may be too much data to process.

提交回复
热议问题