Query Doctor Report
CRITICAL
N+1 detected: 20 queries for table "testapp_author" (via Book.author)
Location: scripts/regen_examples.py:139 in test_regenerate_outputs
_ = b.author.name # N+1 on author
Fix: Add .select_related('author') to your Book queryset
Queries: 20 | Est. savings: ~0.4ms
CRITICAL
N+1 detected: 20 queries for table "testapp_publisher" (via Author.publisher)
Location: scripts/regen_examples.py:140 in test_regenerate_outputs
_ = b.publisher.name # N+1 on publisher
Fix: Add .select_related('publisher') to your Author queryset
Queries: 20 | Est. savings: ~0.3ms
WARNING
Duplicate query: 2 identical queries for table "testapp_book"
Location: scripts/regen_examples.py:142 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: scripts/regen_examples.py:142 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: scripts/regen_examples.py:137 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