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:
|
||||
pass
|
||||
else:
|
||||
for obj in self.page.paginator.object_list:
|
||||
if hasattr(obj, "id"):
|
||||
ids.append(obj.id)
|
||||
elif hasattr(obj, "fields"):
|
||||
ids.append(obj.fields()["id"])
|
||||
ids = self.page.paginator.object_list.values_list("pk", flat=True)
|
||||
return ids
|
||||
|
||||
def get_paginated_response_schema(self, schema):
|
||||
|
Loading…
x
Reference in New Issue
Block a user