Anton Pirker

Anton Pirker

Senior Software Engineer


Finding and fixing an N+1 problem in the Django docs

The N+1 problem is a performance anti-pattern, where your app makes N+1 calls to the database when it could just make one or two. This N+1 problem is common in frameworks, like Django, that use ORM (Object-Relational Mapping) to connect to a database.

Frameworks like Django make it really easy to write an N+1 query without realizing it, and aren’t always easy to find, since they don’t show up as a slow query in database tools.

This talk will define the N+1 problem, then cover how to detect and fix N+1 queries by using an example in the Django documentation site.