SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

Sort memory exceeded only in views #309

Closed johnnywiller closed 6 years ago

johnnywiller commented 6 years ago

Expected Behavior

Return the documents correctly

Current Behavior

500 server error Sort exceeded memory limit of 104857600 bytes.

Context

Hello, I'm been faced with a server error displaying Sort exceeded memory limit of 104857600 bytes.

I know this error happens when we try to sort a large volume of docs, but I'm currently not using any sort operation. In fact I'm querying a view. If I query the collection (the one the view is based), no error happens.

GET localhost:8080/db/collection works fine GET localhost:8080/db/view limit exceed

No sort operation is done in the aggregation pipeline of the view, the resulted amounted of docs returned by the mongo client is less in the view than the collection.

db.collection.count() --> 28k docs
db.view.count() --> 10k docs

Does RH use any default sorting in the view, or have any different behavior based on views?

ujibang commented 6 years ago

fyi, yes RESTHeart has a default sorting, see https://restheart.org/learn/query-documents/#default-sorting

The default sorting of the documents is by the _id descending. To disable default sorting just add the sort={} query parameter