r/SpringBoot • • Sep 16 '26

Question JOOQ vs JDBC

I use JPA for simple CRUD operations (mostly write operations) and JDBC for performance intensive tasks such as sending lists & performing search. The JDBC performance is perfect & the performance of my backend (Spring Boot) is great.

Now, as my project grows, my SQL queries are getting bigger, messier and unreadable. I tried jOOQ and loved it because it made my code super readable, type safe and maintainable. However, after profiling my Spring Boot app, operations that took around 5 ms with JDBC now take 9–14 ms with jOOQ, which makes me reluctant to migrate to jOOQ. Is a 10 ms difference negligible or am I overthinking?

I love the cleanliness and type safety of JOOQ. Would you go this JOOQ route? Have you ever faced such situation? I visited JOOQ's official website and was stunned by the fact it is used by many big organizations

EDIT: Thank you everyone who answered, your insights were amazing. With some tweaks I was able to reduce JOOQ's operation time from 14ms to 7ms and now I have so much clarity in my head.

34 Upvotes

39 comments sorted by

View all comments

0

u/[deleted] Sep 16 '26

[deleted] — view deleted comment

1

u/khan_awan Sep 16 '26

I follow this approach in all of my Spring Boot projects. I use both JPA and Jdbc. JPA for everything and jdbc for performance sensitive stuff and it works great. Performance wise jdbc is perfect and I also love writing custom Sql queries. There are certain things that I don't like about jdbc at scale, like having to write row mappers, losing readability when queries get complex (though I like to keep things small, simple and self explanatory) and lack of compile time safety

1

u/lukaseder Sep 17 '26

 Sure jOOQ abstracts a lot but you can use native queries and shift complex queries to views/functions on the database itself.

How is it different? Why didn't you consider this with jOOQ?

0

u/[deleted] Sep 17 '26

[deleted] — view deleted comment

1

u/lukaseder Sep 17 '26

Let me try again. Why wasn't the conclusion (with jOOQ) to move more logic to views/functions in the database itself? jOOQ would support this very well. You could generate code for all the functions and call them very easily.

0

u/[deleted] Sep 17 '26

[deleted] — view deleted comment

1

u/lukaseder Sep 17 '26

Nah, jOOQ is all about being database first. Point jOOQ at your 1980s ERP with 2000 stored procedures and you'll be just as much of a happy jOOQ user as the one who values super complex dynamic SQL.

It's just a tool. You do with it as you please. I just found it very curious that views and functions would be a better match for JPA when jOOQ fully embraces that, and JPA's function support is very limited... :)