Thoughts about layered architecture – Mapping efficiently with SQL
summary
Argues that reading performance improves by pushing transforms into SQL instead of mapping JPA entities through service mappers, demonstrates using Spring Data projections and optionally jOOQ, replaces a mapper chain that fires 120,000 lazy subselects and causes ~10 minute requests with a 200-line SQL with CTEs that returns the same aggregates in about 3 seconds, and reports smaller gains in typical endpoints (about 72 ms down to 50 ms) while noting added SQL maintenance cost.
AI-written summary · about
chapters (28)
- 0:00Intro
- 0:53KEEP THIS IN MIND
- 2:13I SAW A RECURRING PATTERN!
- 4:53DATA ACCESS
- 5:58DATA TRANSFORMATION
- 8:24WHAT I FOUND IN "THE ARCHIVES"
- 10:39WHAT IS LAYERED ARCHITECTURE?
- 11:11WHAT IS ENTERPRISE SOFTWARE?
- 11:46WHAT IS LAYERING?
- 17:10THIS IS HOW WE BUILD APPS
- 18:14REMEMBER THIS?
- 18:42IT IS OKAY TO SKIP LAYERS
- 19:39SUMMARY: GOALS OF LAYERING
- 21:01DISCLAIMER!
- 21:41DISPLAYING ALBUM INFORMATION
- 22:17HOW THE DATA IS STORED
- 23:26LET'S ADD A FIELD TO "ALBUM"
- 25:52WHAT DATA DO WE NEED?
- 26:21DON'T FETCH EVERYTHING
- 27:20WE DON'T KNOW!
- 29:37BENEFITS AND DOWNSIDES THE BAD
- 30:17MAPPING WITH SQL!
- 30:52FETCH DATA WITH PROJECTIONS
- 31:30CONVERSIONS IN THE DATABASE
- 32:55OF COURSE JOOQ IS MENTIONED
- 34:52REPO IN THE CONTROLLER
- 35:27NON-REPRESENTATIVE METRICS
- 37:00IMAGINE HAVING 200 OF THESE
related talks
45mLazy Versus Eager Loading Strategies for JPA 2.1
44mORM Insights - How not to hurt yourself?
54mDo you really need Hibernate
46mMastering JPA Performance
49mDo You Really Need Hibernate?
49mPerformance oriented Spring Data JPA & Hibernate
58mMaintain Social Distance this Spring
47mWhen ORM Becomes OMG: Performance Pitfalls in JPA and Friends
