How to execute bulk fetch query in mongodb

Hello : )

As been said this is what $facet does,but $facet will not execute each query in parallel,but serial.Also if you want all results to fit in 1 document,this document final size must be<16 MB.

$facet would make sense i think if you had like a common part that could be shared from all queries,before entering the $facet stage,to avoid doing that part many times for each “query”.

If the queries don’t share a common part,i think $facet will cause only restrictions and slower
execution time,from calling the n queries separately,so they can run in parallel,if you call them
in parallel (async or threads)

See this also

2 Likes