mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-18 01:44:53 +00:00
Stream documents in document_archiver via .only() + .iterator()
document_archiver built its document_ids list by materializing every full Document instance (all fields) just to read has_archive_version. Restrict the queryset to the two fields actually used and stream it with .iterator() to avoid loading the whole table into memory at once. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
c753091a44
commit
7d863a553a
@@ -54,8 +54,12 @@ class Command(PaperlessCommand):
|
||||
else:
|
||||
documents = Document.objects.all()
|
||||
|
||||
documents = documents.only("id", "archive_filename")
|
||||
|
||||
document_ids = [
|
||||
doc.id for doc in documents if overwrite or not doc.has_archive_version
|
||||
doc.id
|
||||
for doc in documents.iterator(chunk_size=2000)
|
||||
if overwrite or not doc.has_archive_version
|
||||
]
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user