Unreasonably slow MongoDB query, even though the query is simple and aligned to indexes

后端 未结 3 654
迷失自我
迷失自我 2021-02-04 10:50

I\'m running a MongoDB server (that\'s literally all it has running). The server has 64gb of RAM and 16 cores, plus 2TB of hard drive space to work with.

The Doc

3条回答
  •  悲&欢浪女
    2021-02-04 11:30

    Ok I solved it. The culprit was "scanAndOrder": true, which suggested that the index wasn't being used as intended. The correct composite index has the the primary sort field first and then the fields being queried on.

    { "_id":1, "LastUpdated":1 }
    

提交回复
热议问题