findClips: select_related('item') / ('item__sort')
Clip.public_id uses self.item.public_id. Clip.json() uses self.item.sort, so we should select_related on that rather than the clip's own sort field. (They are identical objects. Is Clip.sort ever used directly?) With this change, findClips() issues one query to fetch clips plus one query per flavour of annotation; before, it issued two extra queries per clip.
This commit is contained in:
parent
6dbb7f921a
commit
ba00bcbf7b
1 changed files with 2 additions and 1 deletions
|
@ -95,6 +95,7 @@ def findClips(request, data):
|
|||
if 'keys' in data:
|
||||
qs = order_query(qs, query['sort'])
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
qs = qs.select_related('item')
|
||||
|
||||
ids = []
|
||||
layers = settings.CONFIG['layers']
|
||||
|
@ -102,7 +103,7 @@ def findClips(request, data):
|
|||
layer_ids = [k['id'] for k in layers]
|
||||
keys = filter(lambda k: k not in layer_ids + ['annotations'], data['keys'])
|
||||
if filter(lambda k: k not in models.Clip.clip_keys, keys):
|
||||
qs = qs.select_related('sort')
|
||||
qs = qs.select_related('item__sort')
|
||||
|
||||
def add(p):
|
||||
ids.append(p.id)
|
||||
|
|
Loading…
Reference in a new issue