inflearn logo

High-Performance Spring Persistence

This course covers the next level of JPA performance optimization beyond Fetch Join and batch_fetch_size. From JPA to Hibernate, JDBC, and the DB engine—you will understand the underlying operational principles and learn seven strategies that can create an 18x performance difference with a single line of configuration. Moving beyond Read optimization, you will tune the entire Spring Persistence layer, including Write performance, relationship pitfalls, and production testing environments. Vlad Mihalcea, a Java Champion and core Hibernate contributor, teaches based on his experience and the tools he personally created to overcome the limitations of Spring Data JPA.

(5.0) 3 reviews

106 learners

Level Intermediate

Course period Unlimited

Java
Java
Spring
Spring
JPA
JPA
database
database
hibernate
hibernate
Java
Java
Spring
Spring
JPA
JPA
database
database
hibernate
hibernate

What you will gain after the course

  • Learn how to remove unnecessary SELECT statements and improve bulk INSERT performance by more than 10 times.

  • Learn strategies to maintain a consistent query speed regardless of the number of pages, even with millions of data records.

  • Experience the 18x performance gap created by a single line of configuration through benchmark figures from 4 different databases.



Learn from a Global Java Champion

High-Performance Spring Persistence Lecture


A high-performance data access layer must be in perfect sync with the underlying database.
Beyond JPA to Hibernate, JDBC, and the DB — this is a journey to optimize the entire data access layer.


Have you ever experienced this?


→ JpaRepository.saveAll()Have you ever discovered it firing unnecessary SELECT queries for every single entity?

→ @DynamicUpdate Have you ever experienced performance degradation after turning it on?

→ Don't know why OFFSET-based pagination gets 20 times slower as you go further back?

→ Did you know that a single line of configuration can make a difference of 550ms → 30ms (an 18x improvement) when querying 100,000 records?

JPA is just the tip of the iceberg
The core is 'below the surface'


To ensure the data access layer works in harmony with the DB,
you must understand the operating principles of Hibernate, JDBC, and the database engine beneath the surface.

This difference is what separates a high-performance application from one that barely runs.



What you will learn in this course

7 Optimization Strategies to Master Spring Performance


From entity mapping to batch processing, relationship pitfalls, lazy loading, and test environments
— learn the core strategies of Spring Persistence performance tuning.


Data Model and Identifier Design Considering Performance

Many developers focus only on adding the @Id annotation, but the choice of identifier strategy determines write performance. save() Learn why SELECT queries are executed even for new entities and why certain ID strategies prevent batch processing.

Before

Commonly used ID strategies + save()
→ Batch INSERT impossible, INSERTs performed one by one per entity

After

By changing the ID strategy and storage method,
→ Process bulk INSERTs at once with JDBC Batch


Operating Principles of Persistence Context and Flush Mechanism

"Why are there so many unintended UPDATE queries?" — No longer leave 'the timing of SQL execution' to guesswork. Analyze the internal workings of Dirty Checking and @DynamicUpdate learn the true criteria for using it.

Before

@DynamicUpdate indiscriminate use
→ can actually cause other performance issues

After

Decision criteria for each situation established
→ Eliminate unnecessary UPDATEs + Maintain cache


JDBC Batch Processing and Statement Caching

Repeatedly calling save() inside a for loop leads to terrible performance degradation once you exceed even 10,000 records. We will go beyond the limitations that cannot be solved with JPA's default behavior alone and apply JDBC batch processing and statement caching to real-world scenarios.

Before

saveAll() executes individual
SELECT + INSERT statements for each entity

After

Replace save method+ JDBC Batching
→ 0 SELECTs + Batch INSERT


Fetch strategy to avoid N+1

Did you think solving N+1 issues ended with fetch joins? There are areas that fetch joins cannot resolve. You will experience a case where bulk inquiry performance improves by 18 times with just a single configuration value.

Before

Querying 100,000 records with default Fetch Size
→ Takes 550ms

After

Add one line of configuration
→ Takes 30ms (18x improvement)


Pagination and Projection for Large-Scale Data Retrieval

"The memory exploded when I tried to fetch all the data." — We acknowledge the fundamental limitations of OFFSET and implement an alternative in a Spring Data environment that maintains a consistent speed regardless of the page number. You will also learn projection techniques to select only the necessary columns.

Before

OFFSET-based pagination
→ becomes 20 times slower as you go further back

After

By replacing OFFSET
→ Consistent response speed for any page


Performance Pitfalls of Relationship Mapping

Setting up relationships is not difficult, but depending on the mapping method, unnecessary tables may be created or Lazy Loading may be ignored. Learn about the relationship performance pitfalls and solution patterns frequently encountered in practice.

Before

In specific association mappings, Lazy loading is ignored
→ resulting in unnecessary tables + additional SELECT queries

After

Switching mapping patterns results in
→ removal of unnecessary tables + Lazy working correctly


Production DB-Based Performance Testing

Even if tests pass with H2, the results can be completely different in the production DB. Learn test strategies to verify performance optimization in a real DB environment.

Before

Testing with H2 in-memory DB
→ Performance issues discovered too late in production

After

Production-identical DB testing
→ Pre-verification of performance issues before deployment


If you've already tried fetch joins, this is where you begin.

Add the fine details that make a difference in the basics to complete the perfection of performance optimization.

The optimization we usually do

  • N+1 Query
    Fetch Join

  • Collection Paging
    default_batch_fetch_size with IN queries

  • DTO Projection
    JPQL new Constructor Expression

  • Bulk INSERT
    Not covered

  • save() overhead
    Not covered

  • @DynamicUpdate
    Not covered

  • Relationship Traps
    Not covered

  • Production DB Testing
    Not covered




Vlad's High-Performance Spring

  • N+1 Queries
    An 18x improvement with advanced strategies beyond Fetch Join

  • Collection Paging
    Maintaining a consistent speed regardless of the number of pages

  • DTO Projection
    Spring Data exclusive lightweight retrieval techniques dành riêng cho Spring Data

  • Bulk INSERT
    Enable Batch INSERT by changing settings and strategies bằng cách thay đổi thiết lập và chiến lược

  • save() overhead
    Completely eliminate unnecessary SELECTs occurring for every entity

  • @DynamicUpdate
    When to turn it on vs. when to turn it off, providing decision criteria

  • Relationship Pitfalls
    Lazy loading failures, unnecessary table creation, and more Solving real-world pitfalls

  • Production DB Testing
    Pre-deployment verification in the same environment as production

The person who created this course

An expert trusted by developers worldwide
Vlad Mihalcea


  • Author of the JPA performance textbook, "High-Performance Java Persistence" (Amazon rating 4.7)

  • 2017, Selected as 'Java Champion' by Oracle

  • Participated in the establishment of the Java Persistence API (JPA) 2.1 standard (JSR 338 Expert Group)

  • Stack Overflow Top 0.1% Contributor

  • Developed Hypersistence Optimizer

  • JPA performance consultant for numerous global top-tier IT companies


Vlad is not just an expert who knows Hibernate well.
He is the person who personally created an alternative library to overcome the performance limitations of Spring Data JPA.
In this course, you will learn directly from him why he created this tool and what problems it solves.


Check out the testimonials from Java Champions around the world!


Rafael Winterhalter
(Creator of Byte Buddy
Java Champion)

Lukas Eder
(Founder of jOOQ
Java Champion)

Markus Eisele
(Red Hat Technical Evangelist
Java Champion)

Whether you use JDBC directly or through JPA or Hibernate, there is no better resource that summarizes the performance impact than this.

This book is a must-read for any developer looking to push the performance of relational databases to the limit with JAVA applications.

Vlad has distilled his vast experience into an easy-to-read book, and it is a must-read if you work with JPA or Hibernate.



Notes before taking the course

Practice Environment

  • Operating System: Windows, macOS, and Linux are all supported

  • Required Tools: JDK 17 or higher, IntelliJ IDEA or Eclipse IDE

  • Build tools: Maven, Gradle

  • Recommended Specifications: 8GB or more of RAM and sufficient disk space

Prerequisites and Important Notes

  • Basic knowledge of Java and the Spring Framework

  • Experience using Spring Data JPA (JpaRepository, @Entity)

  • Basic knowledge of relational databases (RDB) and SQL

  • It will be even more effective if you have experience with Spring-based development in practice.

Learning Materials

  • Lecture slide PDF files are provided.

  • Practice code will be provided through the GitHub repository.

  • There is a quiz at the end of each section to review the lecture content.


🔗 Connection with existing JPA courses

  • Taking other JPA performance courses is not mandatory.

  • If you have already taken it, this course is a complementary rather than a replacement course that will allow you to understand the advanced content more deeply.


  • This is an advanced course that goes beyond basic optimizations like fetch joins and batch_fetch_size.


Frequently Asked Questions

Q. I already know about fetch joins and batch_fetch_size; do I still need this course?

Yes, this course starts exactly from that point. It covers the next level: Write and DB layer optimization.

Q. How is this different from the existing "High-Performance JPA & Hibernate" course?

The previous course EntityManager/Session directly uses APIs and covers the internal workings of the Hibernate engine.
This course solves performance problems actually encountered in a JpaRepository and @Transactional based Spring Data JPA environment.
Even for the same topic of "Batching," the previous course covers "how JDBC Batch works," while this course covers "why batching doesn't work even when using saveAll() in Spring Data."

Q. How much JPA/Hibernate knowledge is required?

Experience with implementing CRUD using Spring Data JPA is sufficient.
If you have used JpaRepository, @Entity, and @Transactional, you will be able to follow all the content. If you have taken the previous course (High-Performance JPA & Hibernate), you can gain a deeper understanding, but it is not mandatory. thì có thể theo kịp tất cả nội dung. Nếu đã học khóa học trước đó (JPA & Hibernate hiệu năng cao) thì bạn có thể hiểu sâu hơn, nhưng đó không phải là điều bắt buộc.

Q. Which database is used?

We provide comparative benchmarks across four databases: MySQL, PostgreSQL, Oracle, and SQL Server.
We also cover how to test in actual production database environments rather than just H2.

Recommended for
these people

Who is this course right for?

  • Those who need the next level of performance optimization after taking the existing JPA performance course

  • Those who have applied fetch joins and batch_fetch_size but are unsure of what to do next.

  • Those who have experienced unexpected queries being sent every time save() is called but couldn't find the cause.

  • Those who have experience with JPA performance tuning but have never delved down to the DB layer.

  • Those who handle large-scale data in practice and need to optimize not only query performance but also write performance.

Need to know before starting?

  • Experience using Spring Data JPA

  • Basic Spring Framework / Spring Boot knowledge

  • Basic knowledge of relational databases (RDB) and SQL

Hello
This is Vlad Mihalcea

Inflearn Verified

1,421

Learners

79

Reviews

4.5

Rating

3

Courses

My name is Vlad Mihalcea, and I’m a Java Champion. I wrote the High-Performance Java Persistence book, which became one of the best-selling Java books on Amazon.

I'm currently developing the amazing Hypersistence Optimizer, and in my free time, I develop various open-source projects (e.g., Hypersistence Utils and FlexyPool) and answer questions on StackOverflow.

I am a Java Champion and a major contributor to the Hibernate ORM project. I created the Hypersistence Optimizer tool, which scans application configurations and mappings to identify the changes needed to speed up the data access layer.

Earned gold badges on StackOverflow by answering thousands of questions related to Hibernate, Java, and JPA tags.

When he finds something interesting, he enjoys sharing it on his personal blog. He believes in open-source software and thinks every developer should contribute in some way.

If he cannot find the right tool, he even starts new open-source projects such as Hypersistence Utils or FlexyPool.

More

Curriculum

All

41 lectures ∙ (6hr 17min)

Course Materials:

Lecture resources
Published: 
Last updated: 

Reviews

All

3 reviews

5.0

3 reviews

  • shyoon135530님의 프로필 이미지
    shyoon135530

    Reviews 1

    Average Rating 5.0

    5

    31% enrolled

    • coiio님의 프로필 이미지
      coiio

      Reviews 6

      Average Rating 5.0

      5

      35% enrolled

      • uheejoon님의 프로필 이미지
        uheejoon

        Reviews 53

        Average Rating 5.0

        5

        32% enrolled

        Similar courses

        Explore other courses in the same field!

        25% off for new members

        $166.70

        25%

        $216.70