|
$graphLookup does not implement many optimizations. We can look at the optimizations for $lookup to see what rewrites can occur since $lookup and $graphLookup have similar behavior. Examples of rewrites that could work are:
- If we have an internal $unwind that has preserveNullAndEmpty equal to true, it can swap with $limit
- If there is no internal unwind, $graphLookup can swap with skip and limit.
- If we have $graphLookup followed by $sort, and $sort does not use any fields created by $graphLookup, they can swap.
There are likely other optimizations in $lookup that can apply to $graphLookup
|