Home / Companies / Sentry / Blog / Post Details
Content Deep Dive

Finding and Fixing Django N+1 ProblemsRemoved

Blog post from Sentry

Post Details
Company
Date Published
Author
Adam McKerlie
Word Count
751
Company Posts That Month
5
Language
English
Hacker News Points
-
Post removed?
Yes
Summary

The author was building a simple website using Django to track expenses and expense reports. They noticed that their application was performing slowly due to N+1 problems caused by the Object-relational mapper (ORM). The ORM was generating multiple queries, including a single initial query and additional queries for each child object, leading to slow performance. By using `prefetch_related()` on the `expenses` field in the `Reports` model and annotating the `total_amount` field, the author was able to reduce the number of database queries and improve the application's performance, resulting in a 91% decrease in page load time.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.