<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ORM on PG Blog</title><link>https://pg-blogs.netlify.app/tags/orm/</link><description>Recent content in ORM on PG Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 03 Jul 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://pg-blogs.netlify.app/tags/orm/index.xml" rel="self" type="application/rss+xml"/><item><title>Avoiding ORM Traps and the N+1 Problem in Java</title><link>https://pg-blogs.netlify.app/posts/8-avoiding-orm-traps-and-n-plus-1-in-java/</link><pubDate>Fri, 03 Jul 2026 00:00:00 +0000</pubDate><guid>https://pg-blogs.netlify.app/posts/8-avoiding-orm-traps-and-n-plus-1-in-java/</guid><description>&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;An ORM like JPA/Hibernate makes database access feel like working with plain objects. That is exactly the problem: a single innocent-looking loop can fire hundreds of SQL queries, and you won&amp;rsquo;t see it until production slows to a crawl.&lt;/p&gt;
&lt;p&gt;This post covers the ORM traps that bite Java teams most often — starting with the notorious &lt;strong&gt;N+1 query problem&lt;/strong&gt; — and the concrete techniques that fix them.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="the-n1-problem"&gt;The N+1 Problem&lt;/h2&gt;
&lt;p&gt;Consider loading authors and printing their books:&lt;/p&gt;</description></item><item><title>Avoiding ORM Traps and the N+1 Problem in Python</title><link>https://pg-blogs.netlify.app/posts/9-avoiding-orm-traps-and-n-plus-1-in-python/</link><pubDate>Fri, 03 Jul 2026 00:00:00 +0000</pubDate><guid>https://pg-blogs.netlify.app/posts/9-avoiding-orm-traps-and-n-plus-1-in-python/</guid><description>&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Python&amp;rsquo;s ORMs — SQLAlchemy and the Django ORM — are a joy to write and dangerously easy to make slow. A loop over a queryset that reads one related field can silently fire hundreds of queries. It looks fine in development and falls over on real data.&lt;/p&gt;
&lt;p&gt;This post covers the ORM traps Python teams hit most, starting with the &lt;strong&gt;N+1 query problem&lt;/strong&gt;, in both SQLAlchemy and Django.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="the-n1-problem"&gt;The N+1 Problem&lt;/h2&gt;
&lt;p&gt;You load authors and print each author&amp;rsquo;s book count:&lt;/p&gt;</description></item></channel></rss>