steevej
(Steeve Juneau)
8
You do a lot of things that hamper performance.
- $sort after $unwind
- storing object id (FormID) as string rather than object id
- $in with large arrays
- using $nin
- having a use case that returns 9 lakhs documents
- $group-ing all the UserResponses and then $slice
For example for $in, if you are querying a list of BusinessID, then they must have some kind of relation between them. Are they from the same country, same region? The you should have a field that represent that grouping and query using the grouping attribute.
Same thing with FormID:$in, why so many form ids, what do they have in common. May be you should have a FormType in addition to a FormID. This way you query on 1 or 2 FormType rather than a big list of FormId.
Ditto for the $nin of Response.Type, your comment type != graph types, seems to indicate that you could a response.TypeGroup field one of graph type and one for ! graph type.