diff --git a/CHANGELOG.md b/CHANGELOG.md index 40a8cd922..d08cecc83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 1.22.1 + +### Improvements +- Reduce memory use in a mongo aggregation pipeline ([#1183](../../pull/1183)) + ## 1.22.0 ### Features diff --git a/girder_annotation/girder_large_image_annotation/rest/annotation.py b/girder_annotation/girder_large_image_annotation/rest/annotation.py index 6483370e0..18b70fa5e 100644 --- a/girder_annotation/girder_large_image_annotation/rest/annotation.py +++ b/girder_annotation/girder_large_image_annotation/rest/annotation.py @@ -630,8 +630,17 @@ def getFolderAnnotations(self, id, recurse, user, limit=False, offset=False, sor pipeline = recursivePipeline + [ {'$lookup': { 'from': 'item', - 'localField': '_id', - 'foreignField': 'folderId', + # We have to use a pipeline to use a projection to reduce the + # data volume, so instead of specifying localField and + # foreignField, we set the localField to a variable, then match + # it in a pipeline and project to exclude everything but id. + # 'localField': '_id', + # 'foreignField': 'folderId', + 'let': {'fid': '$_id'}, + 'pipeline': [ + {'$match': {'$expr': {'$eq': ['$$fid', '$folderId']}}}, + {'$project': {'_id': 1}} + ], 'as': '__items' }}, {'$lookup': {