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

@@ -131,7 +131,12 @@ def get_metadata_cache(document_id: int) -> Optional[MetadataCacheData]:
# The metadata exists in the cache
if doc_metadata is not None:
try:
doc = Document.objects.get(pk=document_id)
doc = Document.objects.only(
"pk",
"checksum",
"archive_checksum",
"archive_filename",
).get(pk=document_id)
# The original checksums match
# If it has one, the archive checksums match
# Then, we can use the metadata