Query Doctor Report
CRITICAL
N+1 detected: 20 queries for table "testapp_author" (field: author)
Location: C:\Users\hassa\Desktop\django-query-doctor\scripts\regen_examples.py:64 in test_regenerate_outputs
_ = b.author.name # N+1 on author
Fix: Add .select_related('author') to your queryset
Queries: 20 | Est. savings: ~0.3ms
CRITICAL
N+1 detected: 20 queries for table "testapp_publisher" (field: publisher)
Location: C:\Users\hassa\Desktop\django-query-doctor\scripts\regen_examples.py:65 in test_regenerate_outputs
_ = b.publisher.name # N+1 on publisher
Fix: Add .select_related('publisher') to your queryset
Queries: 20 | Est. savings: ~0.3ms
WARNING
Duplicate query: 2 identical queries for table "testapp_book"
Location: C:\Users\hassa\Desktop\django-query-doctor\scripts\regen_examples.py:67 in test_regenerate_outputs
Book.objects.filter(title=books[0].title).count()
Fix: Assign the queryset result to a variable and reuse it instead of executing the same query multiple times
Queries: 2 | Est. savings: ~0.0ms
INFO
Missing index: column "title" on Book (table "testapp_book") is used in WHERE/ORDER BY but has no index
Location: C:\Users\hassa\Desktop\django-query-doctor\scripts\regen_examples.py:67 in test_regenerate_outputs
Book.objects.filter(title=books[0].title).count()
Fix: Add to Book's Meta.indexes: indexes = [models.Index(fields=["title"], name="idx_testapp_book_title")]
Queries: 1 | Est. savings: ~0.0ms
INFO
Fat SELECT: 8 columns from "testapp_book" including large fields: description
Location: C:\Users\hassa\Desktop\django-query-doctor\scripts\regen_examples.py:62 in test_regenerate_outputs
books = list(Book.objects.all())
Fix: Use .defer('description') to skip loading large fields, or .values()/.values_list() if you don't need model instances
Queries: 1 | Est. savings: ~0.0ms