Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27437

$graphLookup stage should use Documents instead of BSONObj in the visited set and cache

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.2
    • 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).

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: