SERVER-121078Open
Join optimization: non-join-optimization-enabled NLJ execution may win against HJ in the case of $limit
In the case of a small $limit, the non-join-optimized execution can terminate the processing of the entire query immediately once the $limit is reached. However, if join optimization elects to build any hash tables, those tables need to be built in their entirety, incurring a fixed cost regardless of the $limit. To reproduce, run the following query against the tpch 0.1 dataset: {code:java} {">>>command": {"aggregate":"lineitem","pipeline":[{"$lookup":{"from":"orders","localField":"l_order