Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

404
Views
MongoError: document constructed by $facet is 104860008 bytes, which exceeds the limit of 104857600 bytes

I am getting memory size limit error while running multiple sub-pipelines in $facet. Can someone help me on this issue. Scenario: I have a crown job which runs once a day. I want to execute multiple pipelines using $facet against a collection with millions of documents whenever job is triggered.

[ 
     {
          $facet: {
                  query1: [pipeline_1],
                  query2: [pipeline_2],
                  query3: [pipeline_3]
                  ...
                  query_n: [pipeline_n]
          },
     },
     {
        $merge:{ into: some_collection}
     }
]

I tried db.collection.aggregate([], {allowDiskUse: true});, But still getting same error. What can be the work around on this. Please help.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In most cases using allowDiskUse should eliminate this error this is why i'm suspecting you're using the wrong syntax for it. Depending on your Mongo version there are some hard limitations on certain operators like $graphLookup, these operators will always have a memory error regardless of the allowDiskUse flag usage.

Assuming you don't use any of these operators allowDiskUse will work, here is a syntax example for the nodejs driver:

db.collection.aggregate([], {allowDiskUse: true});

If you are $graphLookup or one of the other limited operators then there's not much you can do. I would start by splitting these $facet stages into separate pipelines. If the problem still persists you'll need to either optimize the aggregation or find a different approach.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!