-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
Fully Compatible
-
Query 2017-01-23, Query 2017-02-13
When $graphLookup was originally implemented, it used the DBDirectClient to issue queries into the foreign collection, which returned results in BSON. During SERVER-25005, we switched from using the DBDirectClient to using a Pipeline object, which gave back Documents instead of BSONObjs. However, we still store BSONObjs in both the visited set and the cache (evidence that it uses BSON here).
Using BSON is likely slower due to the need to convert between the two formats (Document and BSONObj). We already pay the overhead to convert the results from the foreign collection into Documents (since they are wrapped in a Pipeline), so we shouldn't undo that work and put them back into BSON, only to end up putting them in the 'as' field again as Values (which will first convert the BSONObjs to Documents).