Allow Disc Usage for where / sort queries

Hello all,

i ran in a problem with pagination and large data-sets:

QueryExceededMemoryLimitNoDiskUseAllowed]: Executor error during find

usually one can set allow_disc_use: true or similar. But in mongoid i cannot find this option.
Is this not implemented or where do I have to set this parameter?

Best regards,
Andreas

Hi, if your sort operation would exceed the 32MB memory limit, you can specify allowDiskUse in both find and aggregate, for example:

  1. db.collection.find().sort().allowDiskUse()
  2. For aggregation (just a sample):
    db.yourTableName.aggregate( [
    { $match: {…} },
    { $sort: {…} },
    { yourOtherStages …}
    ],
    { allowDiskUse: true }
    )
1 Like

Oops, sorry. For aggregation pipeline, each stage has a memory limit of 100 MB.

Hi,

yes - that’s the way it’s supposed to work, but unfortunately not in mongoid.
The ruby driver has the option for use_disk_space but I can’t find any way to set it in mongoid.

Fallback to the default client forces me to use aggregation on my own, which means I loose all the mongoid magic.