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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 188 additions and 135 deletions

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