Blog

Featured

Fix N+1 Queries in Django with select_related and prefetch_related

An N+1 query runs one query for a list and one more for every row. Use select_related for foreign keys, prefetch_related for many-to-many and reverse relations, annotate counts in the database, and pin the query count in a test.

· 6 min read

Let's build something

Hiring for a backend role, or have a project in mind? Send a message and I will reply by email.

At most 2 links.