Hi,
as Rhys pointed out you can optimize the pipeline query to avoid reaching the 100MB limit.
Also, you can add indexes to speed up queries and aggregation pipelines. However some stages of the aggregation pipeline will not be able to use an index, for example $group cannot use any index. $match instead can use an index. You can find more information in in the pipeline operator and indexes section of the MongoDB documentation.
Could you please provide some documents and the query that is hitting the 100MB limit? Also, please provide the indexes that are in use with the command db.collection.getIndexes
It would also help if you could provide any error log should you have any.
Best Regards,
Ivan
Hi,
I have reformatted the query to make it easier to read:
The first thing I noticed is the $unwind
operations. Depending on the number of elements in the array that you
are unwinding, the number of documents will grow significantly. For
example, depending on how selective is the initial $match,
if the array only has 2 elements, you could potentially end up with
160,000 (i.e. 2 * 80,000) of non-indexed documents, which will
subsequently be unwound again in the second $unwind operation.
Another observation, if it's possible, you should move forward the second $match before $unwind stage, filtering down the number of documents further.
I would also recommend to benchmark performance in isolation per stack. For example, you should time the aggregation execution via mongo shell and exclude your application report display to get more accurate measurement. Without knowing your application stack and how it would process the result returned by the aggregation pipeline, displaying large number of results may cause performance issues.
It is worth mentioning that MongoDB has flexible schema design, and you should take advantage of this by designing your MongoDB data schema for the benefit of your application. i.e. model your document schema to match your application use case.
If you are interested in a private and confidential level of support, you could consider alternative support channels.
Best Regards,
Ivan
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/dfcec6e4-53cd-4d2a-aedd-42af42d5ca12%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.