Cache serialized entities when fetching many annotations

For a scene with ~5600 annotations, of which ~3100 are entities, this
cuts fetching the scene from 12 seconds to 2 seconds.
This commit is contained in:
Will Thompson 2015-09-14 14:08:02 +02:00 committed by j
commit 8759b569da
3 changed files with 42 additions and 11 deletions

View file

@ -100,7 +100,11 @@ def findAnnotations(request, data):
qs = order_query(query['qs'], query['sort'])
if 'keys' in data:
qs = qs.select_related()[query['range'][0]:query['range'][1]]
response['data']['items'] = [p.json(keys=data['keys']) for p in qs]
entity_cache = {}
response['data']['items'] = [
p.json(keys=data['keys'], entity_cache=entity_cache)
for p in qs
]
elif 'position' in query:
ids = [i.public_id for i in qs]
data['conditions'] = data['conditions'] + {