PlanExecutor error during aggregation :: caused by :: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting.

mongo
mongo
170 Points
8 Posts

I'm doing sorting in mongo db in Robo 3T as:

db.getCollection('notifications').find({}).sort({created:-1})

Also tried with aggregate query:

db.getCollection('notifications').aggregate([{$sort: {created:-1}}])

But getting following error message:

Error: error: {
    "operationTime" : Timestamp(1670930556, 3),
    "ok" : 0,
    "errmsg" : "Executor error during find command :: caused by :: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting.",
    "code" : 292,
    "codeName" : "QueryExceededMemoryLimitNoDiskUseAllowed",
    "$clusterTime" : {
        "clusterTime" : Timestamp(1670930556, 3),
        "signature" : {
            "hash" : BinData(0,"s4UXruiYZcUr3F6BqG+3lgIoUPk="),
            "keyId" : NumberLong("7122164698669121538")
        }
    }
}

 

Views: 5084
Total Answered: 1
Total Marked As Answer: 1
Posted On: 13-Dec-2022 04:24

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
4918 Points
28 Posts
         

You should enable allowDiskUse option.

{allowDiskUse: true}

By default, sort operation has a 100MB limit (in memory), enabling that option in your operation will allow to use bigger size.

db.getCollection('notifications').aggregate([{$sort: {created:-1}}], {allowDiskUse: true})
Posted On: 15-Dec-2022 03:09
thanks
 - mongo  15-Feb-2023 06:02
 Log In to Chat