<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: theDog</title>
    <description>The latest articles on DEV Community by theDog (@thedogeg48).</description>
    <link>https://dev.to/thedogeg48</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4083735%2F2f41037c-c513-4654-bf41-a7ab4ec2c23d.jpg</url>
      <title>DEV Community: theDog</title>
      <link>https://dev.to/thedogeg48</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thedogeg48"/>
    <language>en</language>
    <item>
      <title>5 JPQL Patterns That Nearly Killed Our Banking CRM Performance</title>
      <dc:creator>theDog</dc:creator>
      <pubDate>Tue, 18 Aug 2026 18:08:28 +0000</pubDate>
      <link>https://dev.to/thedogeg48/java-spring-boot-performance-issues-and-solutions-5ege</link>
      <guid>https://dev.to/thedogeg48/java-spring-boot-performance-issues-and-solutions-5ege</guid>
      <description>&lt;p&gt;5 JPQL patterns that nearly killed our CRM performance at a banking client. We were shipping customer queries in milliseconds—then scaled to 100k+ records. Here’s what broke us and how we fixed it.&lt;/p&gt;

&lt;p&gt;🔴 Pattern #1: The N+1 Query Nightmare&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Query: SELECT c FROM Customer c&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Looks innocent. Except we fetch INDIVIDUAL, ORGANIZATION, GROUP types—each with separate queries to get their details. 1 query became 100k queries.&lt;/p&gt;

&lt;p&gt;✅ Solution: JOIN FETCH&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT c FROM Customer c &lt;br&gt;
LEFT JOIN FETCH c.details&lt;br&gt;
WHERE c.status = 'ACTIVE'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;One query. All data. Problem solved. We cut response time from 8s to 200ms.&lt;/p&gt;

&lt;p&gt;🔴 Pattern #2: Pagination With JOIN FETCH&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Query.setFirstResult(0).setMaxResults(100)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Sounds good. Except JPQL pagination happens after the JOIN, so you’re paginating wrong data. Nightmare fuel.&lt;/p&gt;

&lt;p&gt;✅ Solution: Two-phase pagination&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1.  Fetch IDs first: `SELECT c.id FROM Customer c WHERE...`(paginate here)
2.  Fetch full objects: `SELECT c FROM Customer c WHERE c.id IN (:ids)`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Double query, but correct results at scale.&lt;/p&gt;

&lt;p&gt;🔴 Pattern #3: Fetching Sub-Collections&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT c FROM Customer c &lt;br&gt;
LEFT JOIN FETCH c.accounts&lt;br&gt;
LEFT JOIN FETCH c.transactions&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You think you’re fetching everything. You’re actually creating a Cartesian product. 1 customer → 1000 rows.&lt;/p&gt;

&lt;p&gt;✅ Solution: Separate queries&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load customers&lt;/li&gt;
&lt;li&gt;Load accounts by customer IDs&lt;/li&gt;
&lt;li&gt;Load transactions by account IDs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More queries, but predictable performance. MapStruct handles the mapping.&lt;/p&gt;

&lt;p&gt;The hard lesson: JPQL is magical until it isn’t. Scale reveals everything.&lt;/p&gt;

&lt;p&gt;Full deep-dive incoming—patterns, benchmarks, and the exact queries that saved us 6 hours of processing time daily.&lt;/p&gt;

&lt;p&gt;Follow for the blog post 🧵&lt;/p&gt;

&lt;p&gt;``&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>microservices</category>
      <category>jpql</category>
    </item>
  </channel>
</rss>
