0

I am using aggregate and facets to implement paging using skip and limit.One facet is used to get the paged data and another facet is used to get total order count.

Db.collection.Aggregate.Match(filter).Facet(facet1,facet2);

When passing page number as 4 and page size as 500, I am getting the exception from mongo db server as pipeline limit exceeds 16mb.I also tried aggregate option allowdiskuse as true,but no use.Can anyone help me regarding it.

Markus
  • 20,838
  • 4
  • 31
  • 55
  • 1
    One option is to use `$setWindowFields` to return the count instead of `$facet` – nimrod serok Jul 26 '22 at 13:53
  • 1
    See [this](https://stackoverflow.com/questions/72838497/getting-count-of-total-documents-when-using-aggregation-along-with-skip-and-limi) for example – nimrod serok Jul 26 '22 at 13:55
  • But my real issue is not about getting the count.In the page number 4(page size 500) data,the total size of the documents exceeds 16 MB.How can I handle it – MATHEW AUGUSTINE Jul 28 '22 at 16:57

1 Answers1

0

I can guess, the BSON document size is more than what mongodb supports See:

MongoDB Size for BSON

The maximum BSON document size is 16MB or 16777216 bytes. All conversions should use base-2 scale, e.g. 1024 kilobytes = 1 megabyte.

REF: https://www.mongodb.com/docs/manual/reference/limits/

Jamshaid K.
  • 3,555
  • 1
  • 27
  • 42