MongoDB 使用 Parse Server 索引建议

MongoDB with Parse Server index suggestion

我将 mongoDB 与 Parse Server 一起使用并遇到 COLLSCAN,即使我有索引也是如此。 我正在访问 _Session table 并找到正确的“_session_token”。 js代码:

  let query = new Parse.Query('_Session');
  query.equalTo('sessionToken', userAuthToken);
  query.include('user');
  var session = await query.first({ useMasterKey: true });

索引:db.Session.createIndex( {"_session_token": 1} );

DocumentDB 分析结果:

 {
    "op": "query",
    "ts": 1595363106950,
    "ns": "production._Session",
    "command": {
        "find": "_Session",
        "filter": {
            "_session_token": "r:03c7703fcb856a97e475d1a306ea4f3b"
        },
        "sort": {},
        "projection": {},
        "limit": 1,
        "returnKey": false,
        "showRecordId": false,
        "$db": "production",
        "$readPreference": {
            "mode": "secondaryPreferred"
        }
    },
    "cursorExhausted": true,
    "nreturned": 1,
    "responseLength": 307,
    "protocol": "op_query",
    "millis": 952,
    "planSummary": "COLLSCAN",
    "execStats": {
        "stage": "SUBSCAN",
        "nReturned": "1",
        "executionTimeMillisEstimate": "902.042",
        "inputStage": {
            "stage": "LIMIT_SKIP",
            "nReturned": "1",
            "executionTimeMillisEstimate": "902.029",
            "inputStage": {
                "stage": "COLLSCAN",
                "nReturned": "1",
                "executionTimeMillisEstimate": "902.026"
            }
        }
    },
    "client": "",
    "user": ""
}

我该怎么办?如果我执行 db.Session.find({_session_token: "xpto"}) 则使用索引,但如果我使用 Parse,就会发生这种情况。

使用以下方法创建索引:

db.getCollection('_Session').createIndex( {"_session_token": 1} );