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 authored and GitHub committed 2024-04-30 07:37:09 -07:00
1 parent 63e1f9f5d3
commit 7be7185418
10 files changed
+188 -135

No files matched your search

+6 -2
View File
@@ -155,8 +155,12 @@ class DocumentClassifier:
def train(self):
# Get non-inbox documents
docs_queryset = Document.objects.exclude(
tags__is_inbox_tag=True,
docs_queryset = (
Document.objects.exclude(
tags__is_inbox_tag=True,
)
.select_related("document_type", "correspondent", "storage_path")
.prefetch_related("tags")
)
# No documents exit to train against