Handcrafts SQL queries a little more to reduce the query count and/or the amount of returned data (#6489)

This commit is contained in:
Trenton H
2024-04-30 07:37:09 -07:00
committed by GitHub
parent 63e1f9f5d3
commit 7be7185418
10 changed files with 188 additions and 135 deletions

View File

@@ -16,9 +16,13 @@ def changed_password_check(app_configs, **kwargs):
from paperless.db import GnuPG
try:
encrypted_doc = Document.objects.filter(
storage_type=Document.STORAGE_TYPE_GPG,
).first()
encrypted_doc = (
Document.objects.filter(
storage_type=Document.STORAGE_TYPE_GPG,
)
.only("pk", "storage_type")
.first()
)
except (OperationalError, ProgrammingError, FieldError):
return [] # No documents table yet