How could I write aggregation without exceeds maximum document size?

Hi Team,

How could I write aggregation without exceeds maximum document size?

Use $match early, make it the most restrictive. Use $project early to remove unnecessary fields. Try to use index for the first $match. Add intermediate $match as soon as you know you can reduce the working set.

2 Likes