<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>N+1-Queries on Hi, I'm Braddy</title><link>https://yeohbraddy.com/tags/n+1-queries/</link><description>Recent content in N+1-Queries on Hi, I'm Braddy</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sat, 04 Jul 2026 15:06:05 +0100</lastBuildDate><atom:link href="https://yeohbraddy.com/tags/n+1-queries/index.xml" rel="self" type="application/rss+xml"/><item><title>Making N+1 query detection actually useful at scale</title><link>https://yeohbraddy.com/posts/making-n+1-query-detection-actually-useful-at-scale/</link><pubDate>Thu, 01 Jan 2026 12:00:00 +0000</pubDate><guid>https://yeohbraddy.com/posts/making-n+1-query-detection-actually-useful-at-scale/</guid><description>&lt;h2 id="why-n1-queries-matter">Why N+1 queries matter&lt;/h2>
&lt;p>An N+1 query is one of the most common performance anti-patterns in applications powered by relational databases. It happens when code loads a collection of records, then lazily fetches an association for each one individually effectively turning what should be 1 query into N+1.&lt;/p>
&lt;pre tabindex="0">&lt;code># 1 query to load users
users = User.where(team_id: team.id)

# + N queries, one per user, to load their profile
users.each { |u| puts u.profile.bio }
&lt;/code>&lt;/pre>&lt;p>At large scale where N might be 100, 200, or 1,000, it&amp;rsquo;s not a great thing:&lt;/p></description></item></channel></rss>