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

mongo
mongo
8 Points
4 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: 323
Total Answered: 1
Total Marked As Answer: 0
Posted On: 13-Dec-2022 04:24

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Teacher
1416 Points
238 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
 Log In to Chat