<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/lazy-jdbc-connections-in-spring-boot-4-1-performance-win--bjm4myj1n" -->

---
title: Lazy JDBC Connections in Spring Boot 4.1 (Performance Win)
description: One property change took connection hold time from 2 seconds down to 15 milliseconds. Lazy JDBC connections in Spring Boot 4.1 is a feature you need to know...
canonical: https://daily.dev/posts/lazy-jdbc-connections-in-spring-boot-4-1-performance-win--bjm4myj1n
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Lazy JDBC Connections in Spring Boot 4.1 (Performance Win) | daily.dev
og:description: One property change took connection hold time from 2 seconds down to 15 milliseconds. Lazy JDBC connections in Spring Boot 4.1 is a feature you need to know...
og:url: https://daily.dev/posts/lazy-jdbc-connections-in-spring-boot-4-1-performance-win--bjm4myj1n
og:image: https://api.daily.dev/og/posts/BJM4MYj1n.png
og:image:alt: Lazy JDBC Connections in Spring Boot 4.1 (Performance Win)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Lazy JDBC Connections in Spring Boot 4.1 (Performance Win)

**[Dan Vega](https://daily.dev/sources/dan-vega)** · 17 min read · 2 upvotes · 0 comments

## Summary

One property change took connection hold time from 2 seconds down to 15 milliseconds. Lazy JDBC connections in Spring Boot 4.1 is a feature you need to know about, and I'll prove the performance difference with real metrics.

In this video, we walk through the new spring.datasource.connection-fetch=lazy property in Spring Boot 4.1. We build a complete demo application with Spring Data JDBC, Postgres, Docker Compose, and Spring Boot Actuator to measure the real-world difference between eager and lazy connection fetching. You'll see exactly when this optimization matters and when it won't help.

- How eager vs lazy JDBC connection fetching works inside @Transactional methods
- How to enable lazy connections with a single property: spring.datasource.connection-fetch=lazy
- Building a demo app with Spring Data JDBC, Postgres, Docker Compose, and Actuator metrics
- Measuring real performance differences using Micrometer metrics via the Actuator endpoint
- When lazy connections pay off (slow remote calls before writes) and when they don't

If you learned something new, smash that thumbs up, subscribe for more Spring Boot 4.1 content, and drop a comment telling me which feature you want me to cover next!

0:00 - The 2 seconds to 15ms result
0:20 - Intro & Spring Boot 4.1 overview
1:15 - Release notes & release highlights page
2:00 - GitHub repo & what we're building
2:50 - Eager vs Lazy connection explained
3:40 - Generating the project on start.spring.io
5:00 - Schema, Customer record & repository setup
6:30 - Building the slow remote client
8:00 - Registration service with @Transactional
9:00 - REST controller endpoint
9:45 - Testing with eager (default) — 2.2 second hold
11:00 - Switching to lazy — 15ms hold time
12:00 - When to use lazy connections (and when not to)
13:00 - Wrap up & what's next

🔗Resources & Links mentioned in this video:
GitHub Repository — Lazy JDBC Connections Demo: https://github.com/danvega/jdbc-lazy-connections
Spring Boot 4.1 Blog Post: https://spring.io/blog/2026/06/10/spring-boot-4
Spring Boot 4.1 Release Notes: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.1-Release-Notes
Spring Release Highlights: https://spring.io/projects/release-highlights

👋🏻Connect with me:
Website: https://www.danvega.dev
Twitter: https://twitter.com/therealdanvega
Github: https://github.com/danvega
LinkedIn: https://www.linkedin.com/in/danvega
Newsletter: https://www.danvega.dev/newsletter

SUBSCRIBE TO MY CHANNEL: http://bit.ly/2re4GH0 ❤️

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=lsaBN1U2EB8>

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java), [#spring-boot](https://daily.dev/tags/spring-boot)

[View this post on daily.dev](https://daily.dev/posts/lazy-jdbc-connections-in-spring-boot-4-1-performance-win--bjm4myj1n)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Lazy JDBC Connections in Spring Boot 4.1 (Performance Win)","url":"https://daily.dev/posts/lazy-jdbc-connections-in-spring-boot-4-1-performance-win--bjm4myj1n","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/lazy-jdbc-connections-in-spring-boot-4-1-performance-win--bjm4myj1n"},"datePublished":"2026-06-25T15:13:43.194Z","dateModified":"2026-06-25T17:00:34.342Z","description":"One property change took connection hold time from 2 seconds down to 15 milliseconds. Lazy JDBC connections in Spring Boot 4.1 is a feature you need to know...","image":"https://i.ytimg.com/vi/lsaBN1U2EB8/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/lsaBN1U2EB8/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Dan Vega","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Dan Vega","logo":"https://media.daily.dev/image/upload/s--qCQZxa91--/f_auto,q_auto/v1773648785/logos/dan-vega?_a=BAMAMiiu0","url":"https://daily.dev/sources/dan-vega"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/lazy-jdbc-connections-in-spring-boot-4-1-performance-win--bjm4myj1n","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java,spring-boot","timeRequired":"PT17M","video":{"@type":"VideoObject","name":"Lazy JDBC Connections in Spring Boot 4.1 (Performance Win)","description":"One property change took connection hold time from 2 seconds down to 15 milliseconds. Lazy JDBC connections in Spring Boot 4.1 is a feature you need to know...","thumbnailUrl":"https://i.ytimg.com/vi/lsaBN1U2EB8/sddefault.jpg","uploadDate":"2026-06-25T15:13:43.194Z","duration":"PT17M","url":"https://api.daily.dev/r/BJM4MYj1n","embedUrl":"https://www.youtube.com/embed/lsaBN1U2EB8"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Dan Vega","item":"https://daily.dev/sources/dan-vega"},{"@type":"ListItem","position":3,"name":"Lazy JDBC Connections in Spring Boot 4.1 (Performance Win)"}]}
```

