0

In my application accessing the database is slow compared to other code, as it has to go over the network.

By my understanding, when wrapping a single database statement in @Transactional in Spring, it does 3 calls to the database. First it sets autocommit to false, then it runs the statement and then it calls commit.

If this is true, wrapping a single statement in @Transactional would almost triple its runtime, if the actual database operation is faster than the network delay (which it usually is in my case). Is that correct?

Specifically I noticed that in spring data-jdbc the methods in the CRUDRepository by default have the @Transactional annotation which would mean they are all 3 times slower than they could be? https://docs.spring.io/spring-data/jdbc/docs/current/reference/html/#jdbc.transactions

findusl
  • 2,454
  • 8
  • 32
  • 51

0 Answers0