mongo sort很慢,使用强制索引后很快 快了10倍 请问有什么影响吗

我大约有100w的数据量skip后非常慢请帮忙看下
下面是执行计划
"command" : {

    "find" : "content",
    "filter" : {
        "status" : 2,
        "channelId" : {
            "$in" : [
                5120,
                5121,
                30722,
                898,
                899,
                32196,
                17928,
                907,
                1037,
                912,
                914,
                29011,
                29012,
                32596,
                32663,
                920,
                924,
                1057,
                32290,
                931,
                32875,
                5103,
                5105,
                5106,
                5107,
                5110,
                952,
                1470
            ]
        },
        "releaseDate" : {
            "$lte" : ISODate("2021-11-05T14:32:57.511Z")
        }
    },
    "sort" : {
        "topLevel" : -1,
        "releaseDate" : -1
    },
    "projection" : {
        "_id" : true,
        "titleImg" : true,
        "shortTitle" : true,
        "quoteTitle" : true,
        "title" : true,
        "titleColor" : true,
        "description" : true,
        "url" : true,
        "txt" : true,
        "releaseDate" : true,
        "editor" : true,
        "author" : true,
        "tagStr" : true,
        "editorCharge" : true,
        "mediaPath" : true,
        "origin" : true,
        "views" : true
    },
    "skip" : 117964,
    "limit" : 22,
    "$db" : "cmsyy",
    "$clusterTime" : {
        "clusterTime" : Timestamp(1636093976, 1),
        "signature" : {
            "hash" : BinData(0,"xxpLvCV1uDJz9hffulWXJsaQp1Y="),
            "keyId" : NumberLong("7006251150622064643")
        }
    },
    "lsid" : {
        "id" : UUID("597026cf-e23c-4efa-8191-90ddd1de5944")
    }
},
"keysExamined" : 118014,
"docsExamined" : 22,
"fromMultiPlanner" : true,
"replanned" : true,
"replanReason" : "cached plan was less efficient than expected: expected trial execution to take 22 works but it took at least 220 works",
"cursorExhausted" : true,
"numYield" : 816,
"nreturned" : 22,
"queryHash" : "E975BCE5",
"planCacheKey" : "5CCAD883",
"locks" : {
    "ReplicationStateTransition" : {
        "acquireCount" : {
            "w" : NumberLong(818)
        }
    },
    "Global" : {
        "acquireCount" : {
            "r" : NumberLong(818)
        }
    },
    "Database" : {
        "acquireCount" : {
            "r" : NumberLong(817)
        }
    },
    "Collection" : {
        "acquireCount" : {
            "r" : NumberLong(817)
        }
    },
    "Mutex" : {
        "acquireCount" : {
            "r" : NumberLong(1)
        }
    }
},
"flowControl" : {
    
},
"storage" : {
    "data" : {
        "bytesRead" : NumberLong(1378154),
        "timeReadingMicros" : NumberLong(1251)
    }
},
"responseLength" : 64078,
"protocol" : "op_msg",
"millis" : 2995,

阅读 1.9k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题