Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Performance: fetch note authors with prefetch instead of one query each (#13790)

shamoon78025df40579
diff --git a/src/documents/views.py b/src/documents/views.py
index 0d3f9de99..29cde306b 100644
--- a/src/documents/views.py
+++ b/src/documents/views.py
@@ -1133,7 +1133,8 @@ class DocumentViewSet(
"custom_fields",
queryset=CustomFieldInstance.objects.select_related("field"),
),
- "notes",
+ # NotesSerializer nests the author, this avoids query per note
+ Prefetch("notes", queryset=Note.objects.select_related("user")),
)
)