fix(api): replace the build of the ids of documents by a single SQL query.
This increases the performance of `/api/documents/` up to 60% on a ~1400 documents database (~600 ms > ~240 ms on laptop). This optimization only applies to the basic "list documents case", not the "search case".
This commit is contained in:
parent
b93f655039
commit
d726344d24
@ -56,11 +56,7 @@ class StandardPagination(PageNumberPagination):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
for obj in self.page.paginator.object_list:
|
ids = self.page.paginator.object_list.values_list("pk", flat=True)
|
||||||
if hasattr(obj, "id"):
|
|
||||||
ids.append(obj.id)
|
|
||||||
elif hasattr(obj, "fields"):
|
|
||||||
ids.append(obj.fields()["id"])
|
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
def get_paginated_response_schema(self, schema):
|
def get_paginated_response_schema(self, schema):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user