Fix: pass document chat queries as a QuerySet instead of a materialized list (#13638)

In tracemalloc based profiling, not materializing the whole Document list
reduced memory to approximately 20% of the baseline, with a peak memory
that scaled with the library size.  Now, the lazt queryset is used and only
the needed pk value is actually contributing to memory
This commit is contained in:
Trenton H
2026-08-11 15:25:08 +00:00
committed by GitHub
parent a99f63e059
commit 59a2651804
3 changed files with 123 additions and 53 deletions
+1 -1
View File
@@ -2267,7 +2267,7 @@ class ChatStreamingView(GenericAPIView[Any]):
if not has_perms_owner_aware(request.user, "view_document", document):
return HttpResponseForbidden("Insufficient permissions")
documents = [document]
documents = Document.objects.filter(pk=document.pk)
else:
documents = Document.objects.filter(
id__in=permitted_document_ids(request.user),